Is -XX:+UseG1GC the correct replacement for -Xincgc?
Asked Answered
U

3

16

Currently, we are using the incremental garbage collector by adding -Xincgc to the java command. In JDK 8 this switch is deprecated. So what's the equivalent replacement for it? -XX:+UseG1GC?

Background: The application has a heap of 8GB and creates a lot of short living objects. I noticed that it often paused for some seconds to do garbage collection. Out of curiosity I added the -Xincgc and found that the pauses were gone and overall performance improved ~4 times.

Unfortunately, I did not find any information about what type of garbage collector the -Xincgc triggers. There's the CMS (Concurrent mark and sweep) and the new G1 (Garbage first). But what do I get with -Xincgc?

Unhand answered 25/11, 2015 at 14:34 Comment(0)
S
15

For Oracle/OpenJDK 8 the default collector on most machines is the Parallel Throughput Collector, except for some 32bit windows machines where it can be the Serial GC.

Xincgc is CMS in incremental mode. The main benefit you're seeing probably is caused by switching from the Throughput Collector to CMS, not from the incremental mode, which is designed for single-core CPUs.

Incremental Mode is also deprecated, so simply enable CMS via -XX:+UseConcMarkSweepGC and see if that works for you. Update: CMS has also been deprecated and then removed in later OpenJDK versions

Of course you can also try G1GC, which is also designed to reach low pause time goals and has the advantage that it does not suffer from fragmentation like CMS does and thus is less likely to experience concurrent mode failures which result in a single-threaded stop the world collection. Update: Newer OpenJDK versions offer additional low-pause time collectors besides G1GC) So, try both and measure.

See also: Oracle's Java 8 GC Tuning Guides

Smiga answered 25/11, 2015 at 14:44 Comment(2)
Very detailed answer! Thanks. I'm going to try -XX:+UseConcMarkSweepGC and -XX:+UseG1GC and see what I get.Unhand
@Unhand what are the final switches you used to solve this problem? I am getting an error when I use -Xincgc.Nert
F
3

Until this option completely deprecated by Oracle in the newer version. We could still use this, by applying the following jvm params:

-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

The later 2 params are for logging on GC activities.

Furrier answered 22/11, 2016 at 17:57 Comment(0)
T
1

SYMPTOMS On multi-processor systems, configuring the Java virtual machine's garbage collector (GC) to use concurrent mark-sweep (CMS) 'incremental' mode will result in slower performance than CMS in regular mode.

Unfortunately, when searching for Java tuning pages on the Web, there are many documents that recommend the use of CMS in incremental mode by setting one of the command-line switches-XX:+CMSIncrementalMode or -Xincgc.

https://support.oracle.com/knowledge/Middleware/1284201_1.html

Tacye answered 6/3, 2022 at 21:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.