I have to allocate an array of pointers. The pointers are about 5000.
The array is about 5000*4 = 20Kb

Should I use VirtualAlloc and waste some bytes (because of the page granularity) or should I use HeapAlloc?
If I call VirtualAlloc I know that my array is page aligned, wich is the best in terms of speed
But if I call HeapAlloc, do I have some kind of alignment?

I need speed optimization and not size optimization
Posted on 2004-07-05 13:01:36 by greenant
For speed optimization always use VirtualAlloc it is the fastest and best. The page size is only 4KB so you are wasting an insignificant amount of memory anyway, granularity is not an issue with 20KB. though for something as small as 20K any allocation scheme is just about as fast as any other.
Posted on 2004-07-05 14:00:42 by donkey
I will use VirtualAlloc.
Posted on 2004-07-05 14:32:41 by greenant
Confirmed - HeapAlloc pages are always dword-aligned :)
Posted on 2004-07-06 03:15:42 by Homer