Garbage collection with parallel collector is much faster that serial collector. As you know today almost all Java applications run on machines with a lot of physical memory and multiple CPUs. The parallel collector, also known as the throughput collector, was developed in order to take advantage of available CPUs rather than leaving most of CPU processes idle. Therefore throughput of parallel collector is much better than serial collector. If you are not aware about garbage collection fundamentals and object generations, then I will recommend you to first read my blog “How memory management (Garbage Collection) works in Java and difference types of Garbage Collectors in Java?”
Young Generation Collection Using the Parallel Collector
The parallel collector uses a parallel version of the young generation collection algorithm utilized by serial collector as shown in figure. If you do not know collection process of serial collector, please first read my blog “Serial Garbage Collector in Java”. It is still a Stop-The-World and copying collector, but performing the young generation collection in parallel, using many CPUs, decreases garbage collection overhead and hence increases application throughput. Figure illustrates the differences between the serial collector and the parallel collector for the young generation.
Old Generation Collection Using the Parallel Collector
Old generation garbage collection for the parallel collector is done using the same serial mark-sweep-compact collection algorithm as the serial collector.
When to Use the Parallel Collector
Those applications running on machines with one than one CPUs and do not have pause-time constraints can use parallel collector for garbage collection. Examples of applications for which the parallel collector is often appropriate, those that do batch processing, billing, payroll, scientific computing, and so on. You may want to consider choosing the parallel-compacting collector (described next) over the parallel collector, since the former performs parallel collections of all generations, not just the young generation.
Parallel Collector Selection
In the Java 5 release, the parallel collector is automatically chosen as the default garbage collector on server-class machines. On other machines, the parallel collector can be explicitly selected by using the
-XX:+UseParallelGC command line option.