Documentation Contents

# Parallel Compaction

- Description
- Enabling Parallel Compaction
- More Information

## Description

Parallel compaction complements the existing parallel collector by performing full GCs in parallel to take advantage of multiprocessor (or multi-threaded) hardware. As the name suggests, it is best suited to platforms that have two or more CPUs or two or more hardware threads. It was first made available in JDK 5.0 update 6; the implementation in JDK 6 contains significant performance improvements.

Prior to the availability of parallel compaction, the parallel collector would perform young generation collections (young GCs) in parallel, but full GCs were performed single-threaded. (During a young GC, only the young generation is collected; during a full GC the entire heap is collected. See the documents referenced below for more details on generations and garbage collection.) Parallel compaction performs full GCs in parallel, resulting in lower garbage collection overhead and better application performance, particularly for applications with large heaps running on multiprocessor hardware.

## Enabling Parallel Compaction

Parallel compaction is not enabled by default; add the option

`-XX:+UseParallelOldGC`

to the `java` command line to enable parallel compaction. (Parallel compaction will likely be enabled by default on multiprocessor hardware in a future release.)

Note that parallel compaction is not available in combination with the concurrent mark sweep collector; it can only be used with the parallel young generation collector. The documents referenced below provide more information on the available collectors and recommendations for their use.

## More Information

The HotSpot documentation page contains links to Garbage Collection Tuning Guides, specific to each release, which include guidelines for choosing the garbage collector that best suits your requirements and techniques that can help reduce garbage collection overhead.

Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved.
Contact Us