The Parallel Garbage Collector
Introduction
The parallel collector is intended for applications with medium-sized to
large-sized data sets that are run on multiprocessor or multithreaded
hardware. It is the default collector in JDK 8. You can enable it by
using the -XX:+UseParallelGC option.
Parallel compaction is a feature that enables the parallel collector to
perform major collections in parallel. Without parallel compaction,
major collections are performed using a single thread, which can
significantly limit scalability. Parallel compaction is enabled by
default if the option -XX:+UseParallelGC has been specified. You can
disable it by using the -XX:-UseParallelOldGC option.
Parallel versus Serial Collector
The parallel collector, also known as throughput collector, is a generational collector similar to the serial collector. The primary difference between the serial and parallel collectors is that the parallel collector has multiple threads that are used to speed up garbage collection.
On a host with one processor, the parallel collector will likely not perform as well as the serial collector because of the overhead required for parallel execution (for example, synchronization). However, when running applications with medium-sized to large-sized heaps, it generally outperforms the serial collector by a modest amount on computers with two processors, and usually performs significantly better than the serial collector when more than two processors are available.
Further Reading
If you are interested in learning more about how the parallel collector works, see The Parallel Collector in the HotSpot Virtual Machine Garbage Collection Tuning Guide. (Note: this link is to the documentation for JDK 21, but the information contained therein applies to the parallel GC regardless of JDK version.)
Last reviewed on Sat Feb 01 2025 00:00:00 GMT+0000 (Coordinated Universal Time)