2 Garbage Collectors

This chapter describes garbage collection tuning options available in Oracle JRockit and HotSpot and compares their functionality and performance.

Note:

Some of the tools described in this document require a commercial license for use in production. To learn more about commercial features and how to enable them, see http://www.oracle.com/technetwork/java/javaseproducts/.

Tuning Garbage Collection

The following table lists important garbage collection (GC) tuning options available in Oracle JRockit and HotSpot.

Table 2-1 Garbage Collectors

Oracle JRockit Garbage Collectors HotSpot Garbage Collectors Note

Throughput collector set using any of these options:

  • -Xgc:throughput

  • -Xgc:genpar

  • -Xgc:singlepar

  • -Xgc:parallel

Throughput collector:

-XX:+UseParallelGC – Use parallel collector for the young generation

-XX:+UseParallelOldGC – Use parallel collector for both young and old generation

On Server-class machines, throughput collector is the default collector.

Since JDK 7u4, using -XX:+UseParallelGC (explicitly set or picked ergonomically) also sets UseParallelOldGC and enables the parallel collector for the tenured generation as well.

The number of parallel GC threads can be controlled using -XX:ParallelGCThreads=n

Low latency collector set using any of the following options:

-Xgc:pausetime

-Xgc:gencon

-Xgc:singlecon

-XX:+UseConcurrentMarkSweepGC

Or

-XX:+UseG1GC

The Java HotSpot VM offers a choice between two mostly concurrent collectors:

  • Concurrent Mark Sweep (CMS) Collector is for applications that prefer shorter garbage collection pauses and can afford to share processor resources with the garbage collection.

  • Garbage-First Garbage Collector is a server-style collector is for multiprocessor machines with large memories. It meets garbage collection pause time goals with high probability while achieving high throughput.

-Xgc:deterministic

(see note)

There is no real-time deterministic collector available in HotSpot.

However G1 collector (enabled using -XX:+UseG1GC) attempts to meet the garbage collection pause time goals with high probability while achieving high throughput.

Note that DetGC was designed to provide really short (for example, 1ms) and highly predictable pause times for collections but G1GC does not promise to work with such short pause times.


HotSpot GC Tuning Guide

For further GC tuning, refer to the following document:

http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/