HomeComputer ScienceMark-and-Sweep Garbage Collector

Mark-and-Sweep Garbage Collector

Interactive 3D mark-and-sweep garbage collector: allocate heap objects, drop references, and watch a real reachability-marking wavefront followed by a sweep phase reclaim unreachable memory, with optional generational (young/old) collection.

Computer Science3DModerate60 FPS📱 Mobile-adapted⇄ 2D version
machine-learning-computer-science-2 ↗ Open standalone

Every managed-memory language — Java, JavaScript, Python, Go — reclaims memory automatically by treating the heap as a directed reference graph and asking one question: can this object still be reached from a root? This simulator renders that heap as a live 3D graph. Allocate objects, wire and drop references between them, and watch a real breadth-first mark phase spread outward from the gold root nodes, followed by a sweep phase that ejects every node the wavefront never touched — the exact two-phase algorithm (and its generational young/old refinement) that runs, invisibly, under almost every program you use.

⚙ Under the hood

Watch a real mark-and-sweep garbage collector at work on a live 3D heap: allocate objects, wire and drop references, then trigger a BFS reachability scan from the roots followed by a sweep that reclaims everything the wavefront never touched, with an optional generational young/old mode.

garbage collectionmemory managementcomputer sciencegraph algorithmsmark and sweepcompilers

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)