- Executable program can either refer to near memory (the stack) or far memory (the heap)
- Accessing the stack is faster than accessing the heap
- The stack is smaller than the heap
- Variables are allocated on the stack
TimeStamp tts;
- Common bug (but hard to trace): stack overflow
char veryLongArray[1000000000];
- Memory allocated on the stack is deallocated automatically
at the end of the scope where it was allocated (closing brace
})
- Memory on the heap can be accessed through user-defined
memory allocation
- Memory on the heap must be deallocated explicitly, otherwise
memory leaks occur, exhausting all the computer's memory
- Memory on the heap
must not be deallocated
more than once (causes unpredictable behaviour)
Leo Liberti
2008-01-12