GC Algorithms
Serial, Parallel, CMS, G1, ZGC
8 min read
GC Algorithms
Different GC algorithms optimize for throughput, latency, or memory footprint.
- Serial GC: Single-threaded, simple
- Parallel GC: Throughput-oriented
- CMS: Low pause times (deprecated)
- G1: Region-based, default in Java 9+
- ZGC: Ultra-low latency
Code Examples
Selecting GC algorithms
bash
1
2-XX:+UseG1GC
3-XX:+UseZGC
4 Use Cases
- High-throughput systems
- Low-latency applications
Common Mistakes to Avoid
- Using wrong GC for workload
- Ignoring GC logs