|
-
December 3rd, 2011, 11:58 AM
#1
malloc/HeapAlloc returns NULL but there is plenty of memory
Hi,
I have a situation in which malloc() returns NULL and sets errno to ENOMEM. But the CRT heap (which is growable) has plenty of memory to work with. At the time of malloc, my process memory is about 900 MB.
The malloc() I'm doing is 80 megabytes, and fails. If I do a 60 MB allocation, it succeeds. After that, a 50 MB allocation, followed by another one, and another one *also succeed*: clearly, I still have a lot of memory left but the 80 MB malloc seems too "big" to digest for the OS.
I'm using Windows 7 x64 SP1 with 4 GB RAM. My process is a 32-bit process. I'm using the Low Fragmentation Heap, which is the default on Win 7 - I have also verified with HeapQueryInformation.
What the heck can cause malloc() to fail if this is not a lack of memory ? Is my memory too fragmented ?? This is really weird, I have never seen this behavior before.
Thanks,
Martin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|