On Apr 7, 2005 4:16 AM, Richard Lindsey <[EMAIL PROTECTED]> wrote:
> Yeah that whole stack/heap concept is still a little fuzzy to me as I
> never really took a programming course higher than TP in high school :D
> 
> Richard Lindsey

It's really pretty simple. The memory in your program is divided into
2 areas (really more, but we'll stick with 2 right now), the stack and
the heap.

The stack is used for temporary storage. When you call a function, all
of that function's variables are created on the stack. When a function
ends, its variables are removed from the stack and the memory is
freed. If you get out of control recursion or just too many function
declaring too many variables, you'll run out of stack space.

The heap is used for permanent storage. When you allocate new memory,
the memory comes from the heap. Global variables are stored on the
heap, so they never go away.
Static variables are stored on the heap, so that they retain their
value between function invocations. If you have a memory leak, you'll
(eventually) run out of heap space.

That's the quick and dirty version, anyway.

-David

Reply via email to