Production GC Implementations: JVM, Go, and .NET
JVM Garbage Collectors
G1 (Garbage First): Default since Java 9. Region based, generational, concurrent. Target pause time configurable (default 200ms). Good balance of throughput and latency for most workloads. Handles heaps up to hundreds of GB.
ZGC: Ultra-low latency collector. Pauses under 1ms regardless of heap size. Uses colored pointers and load barriers. Suitable for terabyte heaps. Higher CPU overhead than G1 but predictable latency.
Shenandoah: Similar goals to ZGC with different implementation. Concurrent compaction via forwarding pointers. Available in OpenJDK. Also achieves sub-millisecond pauses for large heaps.
Go Garbage Collector
Go uses a concurrent, tri-color mark and sweep collector. No generational hypothesis. All objects treated equally. Pauses under 1ms for most workloads, achieved through concurrent marking and write barriers.
Go prioritizes low latency over throughput. The collector targets 25 percent CPU overhead. Heap grows to maintain this target. More memory reduces collection frequency. Trade-off is memory usage for pause time.
.NET Garbage Collector
.NET uses generational collection with three generations. Generation 0 collects most frequently, Generation 2 least. Server mode uses one heap per core for parallelism. Workstation mode uses a single shared heap.
Large object heap (LOH) holds objects over 85 KB. LOH is not compacted by default, leading to fragmentation. .NET 5 added LOH compaction option but it is expensive. Avoid frequent large allocations to prevent LOH growth.