⚙️Stack Memory
Also known as Call Stack, The Stack, Stack Overflow
A small, fast part of memory. It holds the values of running functions.
Think of it like
Think of it like a pile of plates. You add to the top and take from the top.
Example
Lucy's function calls itself with no stopping point. After many thousands of calls the stack is full. The program crashes with a stack overflow.
Why it matters
It is why local values are cheap and vanish after a function ends. It is also why deep recursion can crash.
Definition
Example code
console
$ ulimit -s
8192Common mistake
Key takeaways
- 1Last in, first out. Like a pile of plates.
- 2Freed on return. Nothing to clean up.
- 3Small and fast. Often 8 MB on Linux.