Q: When linking my program with MallocDebug, I get the error message
failed on vm_allocate
in the console when I tried to allocate 43 MB. However, if I relink the exact same program without the MallocDebug library, it runs fine. Why?
Q: When linking in MallocDebug, I noticed that my program VSIZE (using ps -ux) which was 2MB without MallocDebug, would start out way high--well over 20MB. Why?
A: The problem is that MallocDebug requires all of the memory to be allocated contiguously, which means that it must guess how much the program might need and allocate all of that at once at the beginning The current guestimate is 40 MB. This is the reason why when running your program with MallocDebug, you have noticed that the VSIZE went up tremendously.
So if you use MallocDebug, you can only ask for a total of 40 MB over the life of your program. After you cross that barrier, it fails. It doesn't matter if you have freed any or all of the memory you have previously asked for. The indicative error message is : "failed on vm_allocate" when you try to use malloc(), calloc(), or realloc().
There is no workaround other than running your program without using MallocDebug.
Note also that MallocDebug cannot currently be used together with ProcessMonitor.
QA818
Valid for 2.0, 3.0