Something to keep in mind: if a program seems to run out of memory, it may not be a memory leak. It may be that you have one gigantic allocation larger than memory.
Something to keep in mind: if a program seems to run out of memory, it may not be a memory leak. It may be that you have one gigantic allocation larger than memory.
Comments
yeah? who cares? oh...you do.
On some flavors of Unix you can get a memory error at a point later on when you try to use the allocated memory. It works like this: when you allocate memory the OS just allocates page table entries. It hasn't been committed yet. Kinda like an IOU. Time passes, and other applications use up swap space. When your application decides to touch one of those pages the swap file is full. Result: memory fault. Ouch!
A solution to this problem is to touch any memory you
allocate, essentially forcing the OS to commit swap space before you return from the allocation call.
Add a comment: