Skip to content
Back to the catalog
Project garbage-collectorSystemsExpertBeta

A garbage collector

Mark-and-sweep from scratch. Manage memory the way the runtimes you use daily do without you noticing.

Build it in your language

The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.

Guide language

The stage guides read in this language. Only languages this project is fully translated into show up here; the interface language does not change.

What this project is about

If you program in a garbage-collected language, there's a component constantly deciding what lives and what dies in your program, and you've never seen it. Here you write it.

You'll build your own heap with its allocator, a mark-and-sweep collector on top of it, and the improvements real runtimes use: generational collection and compaction. And you'll measure the pauses, which is where the hard part lives.

Roadmap

9 stages across 4 phases. Every stage comes with its guide and its tests: you move on when they pass.

  1. Phase 12 stages

    Your own heap

    Reserve memory, write an allocator, and represent objects with a header.

    1. 01Heap allocator
    2. 02Object layout
  2. Phase 23 stages

    Mark and sweep

    Roots, traversal of the object graph, marking and freeing.

    1. 01Root set
    2. 02Graph marking
    3. 03Sweep
  3. Phase 32 stages

    Keeping it from degrading

    Free list, fragmentation, and automatic collection triggering.

    1. 01Free list
    2. 02Trigger and metrics
  4. Phase 42 stages

    Like the real ones

    Generational collection with a nursery, write barriers, and measured compaction.

    1. 01Nursery and write barrier
    2. 02Measured compaction

Before you start

A complete memory manager for a toy virtual machine: your own allocator over a reserved heap, root scanning from the stack and registers, marking and sweeping, a free list, generational collection with a nursery, and a compaction phase that removes fragmentation.

  • neural-network
    Ready to build

    A Neural Network from Scratch

    Build and train a neural network from first principles: forward pass, loss functions, and gradient descent optimization.

    Beginner6 stages~6 hSystems
    machine learningneural networksmath+1

    Python · TypeScript

  • container-runtime
    Beta

    Build your own container

    namespaces, cgroups and chroot. Isolate a process by hand and understand what Docker does when it starts an image.

    Expert8 stages~16 hSystems
    namespacescgroupsprocesos

    Go · C · Rust

  • shell
    Beta

    Build your own shell

    fork, exec, pipes and redirection. Build a POSIX command interpreter that runs real programs.

    Intermediate12 stages~14 hSystems
    procesosforkexec+2

    C · Rust · Go · Zig