How the .NET generational Garbage Collector optimizes memory management:
- Gen 0: Short-lived objects (temporary variables, loop buffers). Collected frequently in sub-millisecond pauses.
- Gen 1: Buffer zone for objects that survived Gen 0.
- Gen 2: Long-lived objects (static singletons, cache dictionaries). Full GC collections are expensive.
- Large Object Heap (LOH): Objects $\ge 85,000$ bytes are allocated directly on LOH to avoid copying costs during compaction, but can cause address space fragmentation.
- Pinned Object Heap (POH): Objects pinned for native interop to avoid GC compaction barriers.