Stacks Flashcards
Memory layout
- Stack
- Empty space where stacjj and dynamic heap data grows into
- Dynamic Heap Data
- Static Data
- Literals
- Instructions
Instructions (in memory layout)
Read only; executable
Initialized when process starts
Literals (in memory layout)
Read-only; not executable
Initialized when process starts
Static data (in memory layout)
Writable; not executable
Initialized when process starts
Dynamic Heap Data
Writable; not executable
Managed by programmer
Stack (in memory layout)
Writable; not executable
Managed automatically by compiler
When does the stack grow
Each time a function is called
When does the stack contract
Each time we return from a function
Cases where local variables need to be stored in stack memory
Not enough registers to hold local variables
The address operator “&” is applied to a local variable
Local variable is array or structure