How the garbage collector (GC) works in .NET
An interactive managed-heap model: generations 0/1/2, allocation budgets, Mark → Sweep → Compact phases, survivor promotion, and the large object heap (LOH).
Current phase Idle
Ready for the next action
Managed heap
reachable object garbage (unreachable) free space
Gen 0nursery — all new objects start here
Gen 1survived one collection
Gen 2long-lived objects (caches, static data)
LOHobjects ≥ 85,000 bytes; collected only with Gen 2