2 Garbage Collectors

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

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 Notes

Throughput collector set using any of these options:

  • -Xgc:throughput

  • -Xgc:genpar

  • -Xgc:singlepar

  • -Xgc:parallel

Throughput collector:

—XX:+UseParallelGC - Use parallel compacting collector for both young and old generation

-XX:+UseParallelGC -XX:-UseParallelOldGC - Use parallel compacting collector for the young generation and serial mark-sweep for the old generation

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:+UseG1GC

Or

-XX:+UseConcurrentMarkSweepGC

Note:

The CMS collector was deprecated in JDK 9.

The HotSpot offers a choice between the two mostly concurrent collectors:

  • Garbage-First (G1) Garbage Collector is a server-style collector for multiprocessor machines with large memories. It meets garbage collection pause time goals with high probability while achieving high throughput
  • 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

The Garbage-First Garbage Collector is the default collector.

To understand the various garbage collectors that are included with the HotSpot, see Introduction to Garbage Collection Tuning in Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide.