Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

Explain the weak generational hypothesis and how the heap is organised in Parallel GC compared with G1.

The weak generational hypothesis says that most objects die young, so collecting a small area of new objects often is cheap and recovers most garbage. Parallel GC splits the heap into contiguous young and old generations, with the young generation made of eden and two survivor spaces. G1 divides the heap into equal-sized regions, each of which is eden, survivor, old or humongous at a given moment, so generation sizes can change between collections; in both, objects that survive enough young collections are promoted to old, and in G1 objects of half a region or more go straight into humongous regions.

Why this question is asked

Almost every garbage collector tuning conversation starts from generations, and most production GC problems, long pauses, frequent full collections, memory that grows after each young GC, come from objects living longer or shorter than the collector expects. Interviewers ask this to check that we know the idea behind generational collection and how two common collectors lay out memory to exploit it. In this answer, we will recap the hypothesis and why it makes collection cheaper, look at Parallel GC's layout, follow an object through aging and promotion, then look at G1's regions and humongous objects, and finish with premature promotion.

1A Quick Recap: The Weak Generational Hypothesis

Measurements of real programs show a consistent pattern: most objects become garbage very soon after they are created. Think of the strings, iterators, DTOs and temporary collections created while handling one HTTP request; once the response is sent, nearly all of them are unreachable. A small fraction lives much longer: caches, connection pools, Spring beans. This pattern is called the weak generational hypothesis.

A tracing collector's cost depends mostly on the number of live objects it must find and copy, not on the amount of garbage. So if we put new objects in a separate, small area and collect only that area often, most of what we look at is already dead, and the collection is fast: we copy the few survivors out and reuse the whole area. Old objects are collected separately and less often. That is generational collection, and both Parallel GC and G1 use it.

2Parallel GC: Contiguous Generations

Parallel GC reserves the heap as two contiguous parts. The young generation contains eden, where new objects are allocated, and two equal survivor spaces, often called S0 and S1, of which one is always empty. The old generation holds long-lived objects.

Java
// java -XX:+UseParallelGC -Xmx4g -Xmn1g -XX:SurvivorRatio=8 ...
// young = 1 GB: eden 800 MB, S0 100 MB, S1 100 MB (eden is 8x one survivor space)
// old = 3 GB
// note: Parallel GC's adaptive sizing may resize eden and survivors at run time
Heap layout in Parallel GC and G1
AspectParallel GCG1
Structurecontiguous young and old areasmany equal-sized regions
Young generationeden + two survivor spacesa set of eden and survivor regions
Generation sizesset at start, adaptive within limitscan change every collection
Old collectionfull GC of the whole heapmixed GCs of selected old regions
Large objectsallocated normally, often in edenhumongous regions if half a region or more

A young collection, a minor GC, stops the application, copies the live objects from eden and the occupied survivor space into the empty survivor space, and then treats eden and the old survivor space as empty. With 1 GB of young generation and, say, 2 percent of it alive, the collector copies only 20 MB. When the old generation fills up, Parallel GC runs a full collection that marks and compacts the whole heap, which takes much longer.

3Aging and Promotion

Each object carries an age in its header, the number of young collections it has survived. Every time a minor GC copies it from one survivor space to the other, its age goes up by one. When its age reaches the tenuring threshold, it is promoted: copied into the old generation instead of the other survivor space. The maximum threshold is 15 by default (-XX:MaxTenuringThreshold), and the JVM may use a lower threshold dynamically when survivor space is getting full.

Step throughAn object's journey through a generational heap
  1. Allocated in edenmost objects die here
  2. Alive at a young GC?
    YesCopy to a survivor space, age + 1NoReclaimed with eden
  3. Age reached the tenuring threshold?
    YesPromote to oldNoStay in survivor
  4. Survivor space overflowed?
    YesPromote to old earlyNoWait for the next young GC
  5. Collected in oldfull GC (Parallel) or mixed GC (G1)

5 steps in order. Play them, or step through them one at a time.

There is a second path into old: if the survivors of a collection do not fit in the survivor space, the overflow is promoted immediately, whatever its age. This overflow path is the one that causes trouble, as we will see in the follow-up.

4G1: Regions Instead of Fixed Areas

G1, the default collector since JDK 9, divides the whole heap into equal-sized regions, typically from 1 MB to 32 MB each, chosen at start-up so that the heap has around 2,048 regions (check your version for the exact limits; -XX:G1HeapRegionSize overrides it). Each region has a role at any given moment: eden, survivor, old, humongous, or free. The young generation is simply the set of eden and survivor regions, and after a collection the emptied regions return to the free list and can become anything next time.

This is what lets G1 adapt generation sizes between collections. To meet its pause time goal, 200 ms by default with -XX:MaxGCPauseMillis, G1 measures how long it takes to collect each region and chooses how many eden regions to use before the next young collection. Old regions are collected incrementally in mixed collections, which copy the survivors of a few old regions with the most garbage, so G1 rarely needs a full GC of the whole heap.

5Humongous Objects in G1

A region-based layout has a problem with very large objects: copying a 20 MB array between regions at every collection would be expensive, and it may not even fit in one region. So G1 treats any object of half a region or more as humongous and allocates it directly in one or more contiguous free regions, marked as humongous, outside the young generation.

Java
// java -XX:+UseG1GC -Xmx4g ... -> region size 2 MB (4 GB / 2048)
byte[] small = new byte[512 * 1024]; // 512 KB: normal allocation in eden
byte[] big = new byte[1024 * 1024]; // 1 MB = half a region: humongous, own region
byte[] huge = new byte[5 * 1024 * 1024]; // 5 MB: three contiguous humongous regions
// -Xlog:gc+humongous=debug shows these allocations (check your version for the exact tags)

Humongous objects are not copied, and G1 can reclaim short-lived ones early, during young collections, when nothing references them. But many of them waste memory, since the rest of the last region is unused, and they can trigger concurrent cycles or, when contiguous free regions run out, a full GC. A larger region size, or avoiding very large short-lived arrays, often fixes humongous allocation pressure.

6Follow-up questions

What is premature promotion and why does it hurt?

Premature promotion is when objects that are going to die soon are copied into the old generation anyway, usually because the survivor space overflowed during a young collection or the tenuring threshold dropped. Those objects then die in old, where only an expensive full GC (Parallel) or a mixed collection (G1) can reclaim them. The old generation fills with garbage, old collections become more frequent and longer, and in Parallel GC this shows up as regular full GCs with long pauses. The usual causes are a young generation too small for the allocation rate or bursts of medium-lived data, such as a large batch held for a few seconds, and the fixes are a larger young generation or survivor space, or reducing how long those objects live.

Does every collector use generations?

Most do today. Serial, Parallel and G1 are generational. ZGC has been generational since JDK 21, and from JDK 23 the generational mode is the default, with the non-generational mode removed in a later release; check your version. Shenandoah also has a generational mode, so the hypothesis remains the basis of nearly all modern Java collectors.

7Conclusion

In this answer, we saw that the weak generational hypothesis, most objects die young, makes it cheap to collect a small young area often because few objects there are alive. Parallel GC lays the heap out as contiguous young and old generations, with eden and two survivor spaces, while G1 divides it into equal-sized regions whose role changes between collections, so generation sizes can adapt to a pause goal. Objects age in survivor space and are promoted after reaching the tenuring threshold or when survivor space overflows, and in G1 objects of half a region or more are allocated as humongous objects in dedicated regions.

What to say in the interviewAbout 100 seconds aloud

Open with

The weak generational hypothesis is the observation that most objects die young, request-scoped strings, DTOs and temporary collections, while a few live a long time, like caches and beans.

Then, if they want more

A tracing collector's cost depends on live objects, so if new objects go into a separate young area that we collect often, most of it is already garbage, and we only copy a small number of survivors. That makes young collections cheap.

Parallel GC lays the heap out as contiguous generations: a young generation made of eden and two survivor spaces, one always empty, and an old generation. A minor GC copies live objects from eden and one survivor space into the other survivor space; when the old generation fills, it runs a full compacting GC of the whole heap.

G1 instead divides the heap into equal-sized regions, typically 1 to 32 MB, and each region is eden, survivor, old, humongous or free at a given time. Young is just a set of regions, so G1 can change the generation sizes after every collection to meet its pause goal, and it cleans old regions incrementally with mixed collections.

In both, each object has an age that increases every young GC it survives, and it is promoted to old when it reaches the tenuring threshold, at most 15 by default, or earlier if survivor space overflows. In G1, objects of half a region or more are humongous and are allocated directly in their own contiguous regions.

About this answer

Last updated
12 November 2026
Versions it names
Java 21, Java 23, Java 9
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain the weak generational hypothesis and how the heap is organised in Parallel GC...": https://scrivio-interview-library.netlify.app/java/memory-layout/19561ec291/