1. Concept library
  2. Java & Spring Boot
  3. Module 3: JVM internals

Concept

Generational garbage collection

The young and old generations, minor and major collections, promotion, and why the weak generational hypothesis holds.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Trace an object from allocation in eden to promotion into the old generation
  2. Explain the difference between a minor and a major collection
  3. Explain why most objects die young and how collectors exploit it

In practice

A few lines that show Generational garbage collection doing its job.

Bash
# Young collections are frequent and short; old ones are rarer and longer.
java -Xlog:gc* -jar app.jar | grep -E "Pause (Young|Full)"

# Sizing the young generation changes how often short-lived objects are swept
java -XX:NewRatio=2 -jar app.jar

The common mistake

Watch for

Keeping short-lived objects alive just long enough to be promoted, for example by caching request objects. Promoted garbage is cleaned up only by the expensive old-generation collections.

What to know first

Your roadmap puts these before Generational garbage collection, unless you already know them.

How it stays learned

Once a session shows you understand Generational garbage collection, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled
Previous in the module← Garbage collection
Next in the moduleJIT compilation →