Stack and heap are the two growth patterns of one address space, and they answer different questions. This diagram lays out the process memory map — stack at high addresses growing down, heap below growing up — and compares the mechanics side by side: frame push and pop versus free-list search, LIFO lifetime versus arbitrary lifetime, fixed guard-paged size versus flexible virtual ranges. The ordering of the stages walks through both in parallel: what a call does to the stack, what a malloc does to the heap, and what each costs. Fragmentation only exists on one side. The final stage shows why the distinction shapes real code: stack allocation is nearly free but rigid, heap allocation is flexible but must be tracked, freed, or collected.
Stack vs Heap Layout
Stack vs heap: LIFO frames against free-list allocation, lifetime, size limits, and fragmentation in one address space.
The Runtime Theory Team07 stages
trace / request.md
readyIn a process's virtual memory, the stack sits at high addresses and grows downward; the heap grows upward from the program break below it. They grow toward each other.