How Garbage Collection Actually Works
How Garbage Collection Actually Works
Everything your language does to manage memory — explained from the hardware up. We build the mental model step by step: what allocation actually costs, why most objects die young, and why the garbage collector pauses when it does.
Topics covered:
- The generational hypothesis and why it's true for almost every program
- Mark-sweep vs. copying vs. compacting: the three basic algorithms
- Stop-the-world pauses: what happens during a GC cycle and why it's not free
- Concurrent and incremental collectors: trading throughput for latency
- Reference counting vs. tracing: the two fundamentally different models
- Go's tri-color concurrent collector and Java's G1/ZGC
- Why GC pauses happen, how long they last, and what you can do about them
- Allocation strategies: bump allocation, TLABs, and size classes
Related articles
How Garbage Collectors Decide What to Free
Mark-sweep, generational hypothesis, and GC pauses — the physics of automatic memory management and why it's never truly free.
JIT Compilation: Why Hot Loops Become Machine Code
Tiered compilation, on-stack replacement, and deoptimization — when the runtime outperforms the ahead-of-time compiler.
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
What 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.
WatchDepth, delivered weekly
One technical dispatch a week — articles and episode notes before they go public.
One technical dispatch per week. No noise.