Answer:
❓Q7. What triggers Gen 0 vs Gen 2 collection?
Trigger | Generation |
---|
Gen 0 full | Minor GC |
Gen 1 full | Medium GC |
Gen 2 full or memory low | Full GC |
🏁 Final Thoughts
Gen 0: For short-lived objects → collected frequently
Gen 1: For medium-lived → collected occasionally
Gen 2: For long-lived → collected rarely
The CLR GC algorithm is a mark-sweep-compact generational collector — highly optimized for real-world workloads.
In .NET 8+, it’s so smart that manual memory management is almost never required — just follow clean object lifetime practices, and GC will handle the rest.