GC — Be the Garbage Collector
Sweep every object the roots can no longer reach, before the heap fills. Free something still live and it is a segfault. A game about reachability.
You are the garbage collector. Sweep everything the roots can no longer reach.
How to play
- Orange objects are roots — stack locals and globals. They are always alive.
- An object is alive if you can follow references from any root to it. Everything else is garbage.
- Click the garbage before the clock runs out. Click something still reachable and you have freed live memory — segfault, run over.
How it works
Objects appear on the heap with references between them. Orange objects are roots — stack locals and globals — and anything you can reach by following references from a root is alive. Everything else is garbage, and your job is to sweep it before the clock runs out. Click a live object and you have just freed memory something still points at: segfault. From wave 3 the dead objects reference each other in cycles, which is exactly the case a reference-counting collector cannot free and a tracing collector can.
A game about the reachability rule at the heart of tracing garbage collectors. Real collectors also deal with generations, write barriers and concurrency.
Frequently asked questions
How does the game decide what is garbage?
By reachability, computed live: it walks references from every root and marks what it finds. Anything not marked is garbage. That is exactly the mark phase of mark-and-sweep.
Why are some dead objects pointing at each other?
From wave 3 the garbage is linked into cycles on purpose. A reference-counting collector can never free those — each object still has an incoming reference — while a tracing collector like this one simply never reaches them.
Why is clicking a live object fatal?
Because freeing memory that something still references is a use-after-free, the bug behind a large share of real crashes and exploits. The game is unforgiving about it for the same reason your allocator is.