Question 10 · Section 3

What is Old Generation (Tenured)?

IHOP (Initiating Heap Occupancy Percent) — threshold in G1 that triggers Mixed GC. Default 45%: when Old Gen is 45% full, G1 starts background collection.

Language versions: English Russian Ukrainian

Junior Level

Old Generation — Heap area for objects that survived several Young Generation collections. JVM considers them “stable” and collects them less frequently.

Simple analogy: “Storage room” for things you keep for years.

How objects get here:

  • Survived 15 young generation collections
  • Too large for Young Generation

Full GC — in G1 and Parallel GC cleans the entire Heap → long pause (seconds). In ZGC/Shenandoah, Full GC is practically absent.


Middle Level

Collection Algorithms

Algorithm Pros Cons
Mark-Sweep Fast, concurrent Fragmentation
Mark-Compact No fragmentation Long STW

Promotion Paths

1. Tenuring: object reached MaxTenuringThreshold (15)
2. Survivor Overflow: Survivor overflowed
3. Humongous Objects: object > 50% of G1 region

Promotion Failure

Minor GC tries to promote object to Old
  → Old Gen full or fragmented
  → Full GC (STW on entire Heap!)

Solution: increase Old Gen or decrease Promotion Rate

Tuning

-XX:NewRatio=2                    # Old:Young = 2:1
-XX:InitiatingHeapOccupancyPercent=45  # G1: Old GC threshold (IHOP)

IHOP (Initiating Heap Occupancy Percent) — threshold in G1 that triggers Mixed GC. Default 45%: when Old Gen is 45% full, G1 starts background collection.


Senior Level

Free Lists

Without compaction (G1, CMS):
  → GC maintains Free Lists — lists of free blocks
  → Allocation = finding suitable block
  → Slower than Pointer Bumping

Floating Garbage

Objects that died AFTER marking but BEFORE cycle completion
  → Take space until next collection
  → Inevitable overhead of concurrent GCs

Floating Garbage — objects that became unreachable AFTER
GC took snapshot. They won't be collected in this cycle,
but will be collected in the next.

G1 Mixed GC

G1 doesn't clean entire Old Gen at once!
  → Selects the "dirtiest" regions
  → Cleans them together with Young Gen
  → Fits within MaxGCPauseMillis

ZGC and Shenandoah

Concurrent compaction:
  → Objects moved WITHOUT STW
  → Pauses < 1 ms
  → Cost: CPU overhead (Load Barriers)

Best Practices

  1. Avoid Premature Promotion
  2. Monitor Old Gen fill rate
  3. IHOP tuning for G1
  4. ZGC for < 1 ms pauses
  5. Don’t increase Old Gen without analysis

Senior Summary

  • Old Gen = long-lived objects, expensive collections
  • Mark-Sweep vs Mark-Compact — trade-off
  • Promotion Failure = catastrophe for latency
  • G1 Mixed GC = gradual cleanup
  • ZGC/Shenandoah = concurrent compaction

Interview Cheat Sheet

Must know:

  • Old Gen stores objects that survived 15 collections (MaxTenuringThreshold), oversized objects, and on Survivor overflow
  • Full GC cleans entire Heap → long pause (seconds); in ZGC/Shenandoah Full GC is practically absent
  • Two algorithms: Mark-Sweep (fast, but fragmentation) vs Mark-Compact (no fragmentation, but long STW)
  • IHOP (InitiatingHeapOccupancyPercent) — threshold in G1 (default 45%); when Old Gen is 45% full, G1 starts background Mixed GC
  • Promotion Failure: Minor GC cannot promote object to Old → Full GC (STW on entire Heap)
  • G1 Mixed GC: doesn’t clean entire Old Gen, selects “dirtiest” regions, fits within MaxGCPauseMillis
  • Floating Garbage: objects that became unreachable AFTER marking; will be collected in next cycle

Common follow-up questions:

  • What is IHOP and how to tune it? — Threshold for starting concurrent marking in G1; if Promotion Rate is high, increase it (so GC has time); if low — decrease
  • Why is G1 Mixed GC better than Full GC? — G1 cleans Old Gen gradually, region by region; Full GC = STW of entire Heap
  • What are Free Lists? — Lists of free blocks when no compaction; allocation = finding suitable block (slower than pointer bumping)
  • When is ZGC better than G1 for Old Gen? — When SLA < 10 ms; ZGC does concurrent compaction without STW

Red flags (DO NOT say):

  • “I’ll increase Old Gen and the problem is solved” — without analyzing Promotion Rate, this masks the problem
  • “Full GC is normal for production” — Full GC = seconds of pause; for SLA < 100 ms this is unacceptable
  • “Mark-Sweep is better than Mark-Compact” — Mark-Sweep causes fragmentation, which leads to Promotion Failure

Related topics:

  • [[8. What are generations in GC]]
  • [[9. What is Young Generation]]
  • [[13. What is G1 GC]]
  • [[14. What is ZGC]]
  • [[16. What is stop-the-world]]