The Runtime Theory
Runtime & Execution

How Garbage Collection Actually Works

How Garbage Collection Actually Works

05:09#garbage-collection#memory-management#gc#runtime

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

More in Runtime & Execution

Depth, delivered weekly

One technical dispatch a week — articles and episode notes before they go public.

One technical dispatch per week. No noise.