malloc returning NULL

Started by
5 comments, last by GameDev.net 17 years, 5 months ago
ack. couple of us have been banging at this all day. puzzle pieces: - malloc is returning NULL when it shouldn't be. - we have 3GB ram - the app is using 766MB of ram. there is _plenty_ left in theory (we haven't even started to swap at this point) - _CrtCheckMemory() is showing no heap corruption - depends indicates, however, that the app is using _both_ MSVCP71.dll and MSVCP71D.dll ideas other than suicide? =) -me
Advertisement
Commit suici- oh. Um, find out which of the linked-in .LIBs is including the wrong runtime, and rebuild it with the right one. That might fix it. The other alternative is memory corruption; _CrtCheckMemory() is pretty damn good, but it isn't perfect.
how much memory are you requesting from malloc, its possible that memory is fragmented and there isn't a big enough free block to give you.
Very likely memory fragmentation.

I've seen 300 meg allocations fail on a machine with lots of memory. The program was using less than 100 megs on a 2 gig machine. Address space was probably fragmented by dlls being loaded at unfortunate offsets.
Usually this happens because the amount of requested space is invalid -- perhaps negative or uninitialized.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
If your application legitimately needs many hundreds of megs of ram, and you're getting the fragmentation problems described above, you may want to rebuild it on a 64bit compiler?

That would definitely solve address space fragmentation issues.

Mark
You can run out of virtual memory space wich isn't the same thing as fysical, 2Gb is the limit of virtual memory for a single process in windows.

Your application doesn't have a large allocation of virtual memory space. Could be memory mapped files for example(?).

This topic is closed to new replies.

Advertisement