Networking  

What triggers Gen 0 vs Gen 2 collection?

TriggerGeneration
Gen 0 fullMinor GC
Gen 1 fullMedium GC
Gen 2 full or memory lowFull 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.