Memory errors

Friday 9 January 2004This is almost 21 years old. Be careful.

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]
yeah? who cares? oh...you do.
[gravatar]
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:
Comment text is Markdown.