Master the fundamental concepts of jvm internals through this focused micro-challenge.
G1 (Garbage-First) divides the heap into equal-sized regions and collects the ones with the most garbage first. It targets predictable pause times on large heaps, unlike single-heap stop-the-world collectors.
Key mechanisms:
Young collections evacuate live objects from eden regions; mixed collections fold in old regions with high reclaim potential.
For example, a 8 GiB heap split into 2048 regions lets G1 target a 200 ms pause by collecting just 20 regions worth of garbage.
Pause time goals are hints, not guarantees. Under allocation pressure G1 may still collect more regions than planned; pair `-XX:MaxGCPauseMillis` with GC logs to see real behavior.
This exercise asks you to document G1's region model, remembered sets, and SATB write barriers. You will explain how G1 bounds pause time compared to whole-heap collectors.
You will use the same mental model here when reading production interpreter source later in the track. Sketch one concrete input on paper, predict the outcome, then confirm with code. That discipline catches logic errors early and makes debugging far faster when you extend the implementation in follow-on tasks.
Write a C program that documents G1 GC concepts.
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