Mail Archives: djgpp/1997/08/13/09:21:54
Stack: 256K by default. Stores local vars of the current function and all
calling functions still active. Stores also the addresses to return to,
and is sometimes used to pass params to a function, especially
with varargs. Biggest causes of overflows: too many BIG local variables, or
one WAY too big, usually arrays of large dimensions or huge structs; and
unbounded recursive function calls.
Heap: The rest of memory your program can use, not taken up with code. (Or
the code migh be there too...) Parts of the heap may be swapped to disk for
virtual memory. Global variables, static variables, module-level
variables, string constants, array constants, mallocked memory, and objects
allocated in C++ with new all are put in the heap. Real out of memory
errors (malloc returning NULL and new exceptions) usually result from
either INCREDIBLE memory use, or use on a tiny computer, or use of Windows
<grin>, or possibly unbound recursion in something that allocates memory,
such as constructors, functions with new or malloc, and the like.
It can also occur through memory "leaks" when a program dynamically
allocates, with new or malloc, a lot of stuff and deallocates and so
forth, i.e. when opening and closing documents, if there is a bug in your
code that causes some stuff allocated with malloc or new to be missed when
cleaning up.
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -