Memory errors

Friday 9 January 2004

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

[gravatar]
jess 8:30 PM on 10 Jan 2004

yeah? who cares? oh...you do.

[gravatar]
Bob 2:45 PM on 11 Jan 2004

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:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.