A stack is a last-in-first-out memory region that stores local variables for the currently running function and the functions that called it. Values are added and removed only at the top, so the stack has no gaps. section 2.2
Stack memory has a relatively small limit, often about 8 MB. Programs use the heap instead for larger data or values whose size is unknown until runtime, such as arrays and strings. section 2.2
Key properties:
- Supports fast top-only addition and removal. section 2.2
- Holds local variables associated with active function calls. section 2.2
- Avoids gaps because values leave in reverse order from their insertion. section 2.2













