2.4. The Memory


The run-time stack and frames

When a function is called, it gets a frame where its local variables are stored. When the function returns, the frame is destroyed.

Frames are stored in an area of memory called the runtime stack.

Local variables are called automatic variables because memory for them is allocated automatically and deallocated automatically.


The heap

The heap is an area of memory where both allocation and deallocation are explicit.

Unlike Java, C does not have a garbage collector. You need to deal with memory deallocation in the heap yourself.