Q37: How does Generational Garbage Collection work (Eden, Survivor, Tenured)?
Based on the Weak Generational Hypothesis (most objects die young):
- Young Generation:
- Eden Space: New objects allocated here.
- Survivor Spaces (S0 / S1): Survived objects from Minor GC passes copy back and forth between S0 and S1.
- Old Generation (Tenured): Objects surviving threshold age (e.g., 15 GC cycles) promote to Old Gen.
- Minor GC: Collects Young Gen.
- Major / Full GC: Collects Old Gen (and full heap). Causes longer Stop-The-World (STW) pauses.
Key Takeaways
- Eden -> Survivor (S0/S1) -> Old Generation promotion.
- Minor GC cleans Young Gen fast; Major GC cleans Old Gen with longer STW pauses.
Knowledge Check
Where are newly instantiated Java objects allocated first by default?