PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

I want to allocate 16Mb but can't

I'm developing an application based on ipaq hx4700. I'd like to get 16Mb memory(256*256*256 chars), but I can't! It worked on h5550 perfectly. h5550 has 128Mb memory(and 4700 = 64Mb) but I think it doesn't matter because one process can get just 32Mb memory(<-Am I right? :roll: ).
With GlobalMemoryStatus(), there's enough memory spaces to get 16Mb. I tried with malloc and VirtualAlloc but failed. I tested and I can get *just* 8Mb memory.
It's not a problem about *allocate and free again and again*. I just allocate 16Mb when my application is started, and free it when I quit. What can I do? I'm going crazy... lol
I allocate huge chunks of memory via memory mapped files. CreateFileMapping(NULL,...)
either use CreateFileMapping() or (what i find more straight forward) VirtualAlloc() like this:

Code:
void* ptrVirt = ::VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
void* ptr = (unsigned char*)::VirtualAlloc(ptrVirt, size, MEM_COMMIT, PAGE_READWRITE);


both the VirtualAlloc() as well as the CreateFileMapping() method will give you large memory blocks OUTSIDE the process's memory slot - which is good in any case. for the VirtualAlloc() method this is only true for memory blocks of least 2MB size.

bye,
Daniel
matt99 · 11 Sep 2005, 11:18 UTC — wow!
Thanks guys, you saved me :lol:
CreateFileMapping has one side-effect. It commits only needed areas of memory. This can save RAM, but can also cause problems if there would not be enough memory to commit. In this case you would get strange exceptions or your program would crash silently.
for my current research project i need more RAM than a process memory slot (especially counting DLLs in) can provide.

Doug Lea's heap implementation already uses VirtualAlloc under Windows, so i only had to make sure, that 2MB blocks are reserved in order to have a custom heap that can use all of the PDA's memory.

i wish that MS would one day remove this ugly 32MB barrier from WinCE. at least under WinCE 5.0 this issue is still the there.

bye,
Daniel