Generations, GC roots, and reachability
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
explain how the GC decides what is garbage.
Planned topics
- An object is live if reachable from a GC root: thread stacks, static fields, JNI references.
- Weak generational hypothesis: most objects die young, so collect the young generation often and cheaply.
- Survivors are copied between survivor spaces; after enough collections they are promoted to old.
- Old generation is collected less often; a leak shows up as old-gen growth.
- Unreachable cycles are collected; reference counting is not used.
Draft outline details
Demonstration
a diagram: roots -> objects; Eden -> Survivor -> Old; an unreachable island marked as garbage.
Check your understanding
Is an object in a static map live?
Show answer
Yes, while the map is reachable from a static root, even if never read.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.