data.d

JimBob jim at bob.com
Thu Jul 15 07:14:49 PDT 2010


"Vladimir Panteleev" <vladimir at thecybershadow.net> wrote in message 
news:op.vfvnf1bvtuzx1w at 89-28-59-99.starnet.md...
> On Thu, 15 Jul 2010 11:03:57 +0300, JimBob <jim at bob.com> wrote:
>
>> VirtualAlloc returns chunks that have 'dwAllocationGranularity' 
>> granularity,
>> which is 64K on every Windows OS I've used. So allocating a page, 4K, 
>> will
>> actualy get you 64K.
>>
>> So using VirtualAlloc as a replacement for malloc is very wasteful unless
>> the allocations are larger that 64K.
>>
>> You might want to look at HeapCreate and it's siblings. (on windows 
>> anyway)
>
> dwAllocationGranularity only controls the granularity of the allocation 
> address, but not of the allocation size. A simple program that calls 
> VirtualAlloc 16384 times uses up 1 GB of the address space, but only 64 MB 
> of actual memory. So, while it is a waste of address space, it's not a 
> waste of system memory.

Appologies, msdn says you're right.

Which sucks cause I recently rewrote a bunch of code because of that 
misunderstanding.

Thanks.





More information about the Digitalmars-d-announce mailing list