The layout of a program in memory is as follows:
- Stack — Temporary, local scope data (params, local variables).
- Heap — Dynamically allocated memory (e.g. Malloc).
- Data — Global variables
- Text — Executable code
There is sufficient space between the Stack and Heap sections to allow them to expand.