views:

180

answers:

1

I am routinely seeing VirtualAlloc calls to reserve memory fail. I'm requesting 2MB so that the allocations do not count against my per process virtual memory and instead use system shared memory. At the time of failure, the system reports having over 100 MB available in physical memory.

I'm running on a windows mobile 6.1 device. So far this is a device-specific problem. It works on many identical devices and fails on one device. I would like to be able to determine if other processes on this device are reserving shared memory and therefore preventing me from doing so. Not sure how i can do that though.

This is the doc I am relying on and I see nothing that would explain this problem: http://msdn.microsoft.com/en-us/library/aa908768.aspx

Any ideas? Thanks.

+1  A: 

I'm tempted to say that VirtualAlloc has run out of (contiguous) virtual address space, at least as far as your process is concerned.

I'd first try to establish to which memory slot those previously successful VirtualAlloc chunks got mapped to, and based on that see whom I am fighting with for address space. You should be able to do this either programatically or by using a tool from William J. Blanke (or other similar tools.)

vladr
I'm tempted to agree.
ctacke
Thanks for the links. Are you suggesting that there are no contiguous blocks within my app's 32 MB space (is that what you meant by 'at least as far as your process is concerned'?). Isn't the whole idea that the large 2MB alloc is taken from the higher shared memory region so it doesnt involve my app's Virtual Addr space? In which case the only reason I could think of for this failure is if another process is aggressively reserving shared memory as well. As far as i can tell though, that is not happening. Am I missing something? Thanks.
glutz78
Read http://www.tech-archive.net/Archive/WindowsCE/microsoft.public.windowsce.embedded.vc/2004-11/0364.html -- the part about `VirtualAlloc` sometimes coming from your process' area may have never been true, or may no longer be true, but it warrants examination. Were you able to use William's tool (or the Remote Memory Viewer), and/or log which slot (Windows CE 5) `VirtualAlloc` serves addresses from, leading up to the failure?
vladr
The VirtualMemory.exe tool is quite nice, however it only shows me the lower half of memory and not the top half which is the shared memory area. Am i missing something?
glutz78