Im convertings some C++ source to asm, and in one class, they define *alot* of private data.

1*32768 Doubles, and 8 * 32768 Qwords. (this is alot of mem).

Which is better to allocate this. In total there is 2^15 + 2^6*2^15 bytes, or 2.2 Mbytes of memory!

And this 'class' will be instanciated twice over. So my question is,
What is the fastest/best memory choice (heap, global, or virtual)?

I plan to make one memory allocation, for 2.2Mb. And then i will access regions of memory via a structure.

Im thinking virtual memory, but im not sure?? (I always get hung up on this type of decision problem)

If anyone has any good "rule of thumb" to deciding, i would like to learn it :)

Thanx in advance
:alright:
NaN
Posted on 2002-05-23 19:14:23 by NaN
NaN,

If its access speed you are after, I would be inclined to go for HEAP that is NOT swapped out to disk. Virtual memory always runs the risk of disk swapping that will slow it down a lot.

Regards,

hutch@movsd.com
Posted on 2002-05-23 21:33:10 by hutch--
PSDK says...

Windows 95/98/Me: The heap managers are designed for memory blocks smaller than four megabytes. If you expect your memory blocks to be larger than one or two megabytes, you can avoid significant performance degradation by using the VirtualAlloc or VirtualAllocEx function instead.


Thomas
Posted on 2002-05-24 01:39:31 by Thomas
I think in win32 to differ memory between "heap, global or virtual" is wrong. Better is to differ between

1. address space (or uncommitted memory)
2. committed memory (assigned to physical memory or swap file space)
3. locked memory (always assigned to physical memory)

with Virtualalloc, you can alloc chunks in pages of types 1 + 2, and can transfer type 2 to 3 with VirtualLock (at least in theory)

with HeapAlloc, LocalAlloc or GlobalAlloc, you get memory chunks of type 2 in bytes. To avoid swapping, you may also use VirtualLock.

There may be some performance penalties with very large memory blocks allocated with Heap-, Local- or GlobalAlloc.
Posted on 2002-05-24 04:27:47 by japheth
Thanx for that synopsis Japheth. It makes sense, especially after Thomas' addition ;)

I will use virtual alloc, and lock it before i enter the agressive routines on the memory blocks...

:alright:
NaN
Posted on 2002-05-24 08:01:35 by NaN