Skip to content
Back to the catalog
Project garbage-collectorSystemsExpertComing soon

Build your own garbage collector

Build a garbage collector from scratch. Implement mark and sweep, track live objects and reclaim memory like the runtimes you use every day.

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

Project in preparation: we are completing and verifying the implementation path and its tests. The capabilities below describe the project goal; starting the project is not enabled yet.

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.

  2. Phase 23 stages

    Mark and sweep

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

  3. Phase 32 stages

    Keeping it from degrading

    Free list, fragmentation, and automatic collection triggering.

  4. Phase 42 stages

    Like the real ones

    Generational collection with a nursery, write barriers, and measured 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.

  • container-runtime
    Coming soon

    Build your own container runtime

    Build a container runtime from scratch. Isolate processes with namespaces, cgroups and chroot to understand how Docker starts an image.

    Expert8 stages~16 hSystems
    namespacescgroupsprocesses

    Go · C · Rust

  • neural-network
    Beta

    Build your own neural network

    Build a neural network from scratch. Implement the forward pass, loss functions and gradient descent, then train and run your own model.

    Beginner6 stages~6 hSystems
    machine learningneural networksmath+1

    Python · TypeScript

  • shell
    Coming soon

    Build your own shell

    Build a POSIX shell from scratch. Use fork, exec, pipes and redirection to write a command interpreter that runs real programs.

    Intermediate12 stages~14 hSystems
    processesforkexec+2

    C · Rust · Go · Zig