gc-viz
Tri-color mark-sweep on a tiny heap. Two roots point into a live object
graph; a two-node island (e ↔ f) and a lone g sit unreachable and
will be swept.
The visible invariants:
- During mark, once a node goes
blackit never becomeswhiteorgreyagain. - When the
greyset is empty, every node reachable from roots isblackand every unreachable node stayedwhite. - Sweep removes exactly the
whiteset.
The pure model lives in wal-sh.tools.gc-viz.core (host-neutral
.cljc); the SVG rendering is wal-sh.tools.gc-viz.browser.
Adapted from Peter Zhu's RubyConf 2026 talk Building the
Next-Generation Garbage Collector in Ruby – Ruby is moving to MMTk
(memory management toolkit); tri-color mark is the primitive
underneath. Build: gmake tools-cljs; debug: gmake dev-tool TOOL=gc-viz.