Master the fundamental concepts of garbage collection through this focused micro-challenge.
Most objects die young. Split heap into young (nursery) and old generations. Minor collections copy survivors with copying GC; promote long-lived objects to old gen. Major collections run rarely. HotSpot's G1 and .NET GC extend this model.
Allocate in nursery until full. Minor GC copies survivors to survivor space or promotes. Old gen collected less often with mark-sweep or mark-compact.
cLoading…
Production compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement generational garbage collection with nursery and old generation. This exercise requires a fast minor collection, promotion policy, and write barriers for cross-generation pointers.
Implement generational garbage collection.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github