Java / Java 17 Garbage Collection Interview Questions
What is the difference between G1 GC and Parallel GC?
Both use multiple threads and are generational, but they optimize for different goals and use very different heap layouts.
| Aspect | G1 GC | Parallel GC |
| Heap layout | Many equal-sized regions | Fixed contiguous young/old generations |
| Primary goal | Configurable, predictable pause times | Maximum throughput |
| Old-gen collection | Incremental, via mixed collections | Full stop-the-world compaction |
| Concurrency | Concurrent marking phase | Entirely stop-the-world |
In practice, G1 is the better default for latency-sensitive services, while Parallel GC can still edge it out on raw throughput for batch or offline jobs that don't care about individual pause lengths.
More Related questions...