Skip to content
Ameen Abozaid
Planned lessonMID-002-L02

Generations, GC roots, and reachability

  • Lesson 2 of 7
  • Mid-level
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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.