Medium👤 3-5 years👤 8-15 years 1 min read

Why is the heap split into young and old generations, and what's a minor vs major GC?

Asked inAmazonMicrosoftDeloitte
#generational gc#young gen#old gen#eden#survivor#minor gc
Report issue

⚡ Short Answer

The weak generational hypothesis: most objects die young. So the heap splits into Young (Eden + 2 Survivors) collected often and cheaply (minor GC), and Old (tenured) collected rarely (major/full GC). Survivors that age past a threshold are promoted to Old.

Coffee Chat Question

Concept Made Simple

Why is the heap split into young and old generations, and what's a minor vs major GC?

🧠Mind Map Answer

Remember It Faster

Edennew objects allocate here
Survivor S0/S1survive a minor GC, age++
Old/Tenuredlong-lived, major/full GC
Promotionage ≥ threshold → Old

🔥What If?

Think Beyond the Expected

Allocation rate is huge and minor GCs are frequent — is that bad?

Not necessarily. Minor GCs are cheap because most young objects are already dead (copying only survivors). Frequent minor GC with short pauses is fine; the problem is when objects get prematurely promoted to Old, causing expensive major GCs.

😂Real World

Generational GC is why allocating lots of short-lived objects (per-request DTOs) is usually cheap — they die in Eden and never reach Old gen. Premature promotion (from undersized young gen) is a classic tuning issue.

🎯Interviewer's Expectation

Keywords they're listening for:

weak generational hypothesisEden/Survivor/Oldminor vs major/full GCpromotion by agecopying collector for young

⚠️Common Mistakes

  • Assuming frequent minor GC is a problem
  • Undersized young gen causing premature promotion
  • Confusing major GC with full GC

Best Practices

  • Size young gen to keep short-lived objects out of Old
  • Watch promotion rate, not just GC count
  • Profile allocation before tuning

🔁Follow-up Questions

  • 1What is premature promotion and how do you fix it?
  • 2How does the survivor-space tenuring threshold work?
  • 3Why is a minor GC a 'copying' collection?

🧩Related Technologies

G1Parallel GCGC logs

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Garbage Collection (JVM)
Interview question: "Why is the heap split into young and old generations, and what's a minor vs major GC?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.
Open inChatGPTGeminiClaude

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions