- Text: The executable code (source code compiled to binary)
- Data: initialized or uninitialized data
- Heap: Dynamic allocated memory during program run time
- Stack: Temporary data storage when invoking functions (local variables, function parameters, return addresses)
The sizes of
data are fixed.
stack can grow and shrink during run time. Each time a function is called, a record contains local variables, function parameters, return addresses is pushed to the
stack. When the function finished, that record will be popped from the stack.
heap will grow as memory is dynamically allocated, and shrink when the memory is returned to the system. Notice that
heap size can grow toward each other but the OS has to make sure that they won’t overlap one another.