5.10.4. Areas of Memory

For the purposes of this course, we can break the memory into three areas.

Static area

The static area of memory is of fixed size. Part of it holds things that do not change while the program runs, including:
  • the machine language program;
  • constants, including string constants.
That part of the static area is marked read-only, and your program is not allowed to change it.

A second part of the static area holds global variables, which can be changed by the programs, but that always occupy a fixed number of bytes. The area is called static because its size does not change while the program runs.

Run-time stack

The run-time stack holds frames, where each frame holds information about one function call, including the function's variables, information about which function called it, and some information to help the program manage the run-time stack. The run-time stack grows and shrinks as the program runs. When a function is called, a frame is created for it in the run-time stack. When a function returns, its frame is removed.


When a function returns, its entire frame, including all of its local variables, is removed. So the memory occupied by the local variables cannot be used after the function returns.

The heap is another area of memory that can grow and shrink, but where you have direct control over when memory is allocated and when it is deallocated. The next page explains how to allocate and deallocate memory in the heap.


  1. What is stored in the static area of memory? Answer

  2. What is stored in the run-time stack? Answer

  3. How is memory allocation and deallocation managed in the run-time stack? Answer

  4. What is the heap for? Answer

  5. How is memory allocated and deallocated in the heap? Answer