Java / Java 17 Garbage Collection Interview Questions
What is the young generation in the JVM heap?
The young generation is the portion of the heap where all new objects are first allocated, made up of one Eden space and two Survivor spaces (S0 and S1).
It exists because of the weak generational hypothesis: most objects die shortly after creation, so concentrating collection effort on a small, fast-to-scan area catches the majority of garbage cheaply. A collection of just this area is called a minor GC.
Objects that keep surviving minor GCs get copied between the survivor spaces, aging with each cycle, until they are eventually promoted into the old generation.
More Related questions...