Skip to main content

Explain all GC generations and what makes Gen2 and LOH behave differently.

Expert C#
Quick Answer Gen0 collects frequently and cheaply รขโ‚ฌโ€ most objects die here. Gen1 is a buffer between Gen0 and Gen2. Gen2 collects rarely but is expensive รขโ‚ฌโ€ it scans the full heap. The Large Object Heap (LOH, objects >= 85KB) is collected only during full Gen2 GCs and is not compacted by default, leading to fragmentation.

Answer

Generations:

  • Gen0: short-lived objects.
  • Gen1: buffer generation.
  • Gen2: long-lived objects; full GC expensive.
  • LOH: >= 85KB, collected only in full GC.
  • POH introduced for pinned objects.
  • GC modes: Server, Workstation, Concurrent.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice