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.