Stack vs. Heap Memory
Every local variable is a slot on a stack; every long-lived object is a block on the heap. This video contrasts the two at the machine level: the stack pointer moving up and down with push and pop, the heap as a free list of blocks managed by an allocator, and the performance gap — nanoseconds for stack allocation, tens of nanoseconds plus fragmentation risk for heap allocation.
Topics covered:
- The stack: frame layout and why deallocation is free
- Why recursion grows the stack and what a stack overflow actually touches
- The heap: the allocator's free lists, size classes, and coalescing
mallocandfree: arenas and why most allocs never hit the kernel- Escape analysis: when a compiler puts your "heap" object on the stack
- Value vs. reference semantics and where each type of data lives
- Fragmentation and why allocation patterns decide bandwidth
Related articles
Boxing, Unboxing, and Value vs Reference Semantics
Why every boxed int is a heap allocation, why int[] beats ArrayList and Integer[] by 4-16x, how Java generics erasure forces boxing, and how C# structs avoid it.
String Interning and Memory: Why Some == Comparisons Are Instant
How compilers and runtimes intern strings into symbol tables and pools, why identity comparison works on interned strings, and how Java, C#, and Python each behave.
What Happens When You Allocate an Object
Thread-local allocators, TLABs, bump allocation, and why object allocation is nearly free until the moment it isn't.
More in Runtime & Execution
How Garbage Collection Actually Works
A visual walkthrough of mark-sweep, generational collection, and concurrent GC — the algorithms that keep your memory clean.
WatchWhat Your Code Does Before main()
The loader, the linker, the dynamic linker, and the runtime — everything that happens between pressing run and your first line of code.
WatchHow Threads Actually Work
The kernel scheduler, context switches, goroutines versus threads — a visual walkthrough of what 'running on a core' really means.
WatchAsync/Await Under the Hood
What async/await compiles to — state machines, continuations, and the executor — and how your async function actually runs on one or many threads.
DetailsVirtual Machines Explained
How language VMs like the JVM and the CLR work — bytecode verification, the execution engine, and the runtime services beneath your program.
DetailsInterpreters vs. Compilers
What an interpreter actually does at runtime versus what a compiler does before — ASTs, bytecode, and why the boundary keeps blurring.
DetailsReference Counting vs. Tracing GC
The two families of automatic memory management — refcounts, cycles, and ARC versus tracing collectors, roots, and reachability — compared on real trade-offs.
DetailsThe Event Loop, Visualized
How Node.js and the browser run one thread with many tasks — the call stack, the task queue, and microtasks — animated frame by frame.
DetailsJIT Compilers Explained
How just-in-time compilers work — profiling, tiered compilation, and generating machine code at runtime — from interpreter to native in microseconds.
DetailsDepth, delivered weekly
One technical dispatch a week — articles and episode notes before they go public.
One technical dispatch per week. No noise.