Is -XX: + UseG1GC is the correct replacement for -Xincgc?

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

Background: The application has a bunch of 8 GB and creates many short-lived objects. I noticed that he often stopped for a few seconds to do garbage collection. Out of curiosity, I added -Xincgc and found that the pauses were gone and the overall performance improved ~ 4 times.

Unfortunately, I did not find any information about what type of garbage collector runs -Xincgc . There CMS (simultaneous marking and sweep) and the new G1 (garbage first). But what will I get with -Xincgc ?

+8
source share
2 answers

For Oracle / OpenJDK 8, the default collector on most machines is a parallel bandwidth collector, with the exception of some 32-bit window machines, where it might be a Serial GC.

Xincgc is a CMS incremental. The advantage that you see is probably due to the transition from the bandwidth collector to the CMS, and not from the incremental mode, which is intended for single-core processors.

Incremental mode is also deprecated , so just enable CMS via -XX:+UseConcMarkSweepGC and see if this works for you.

Of course, you can also try G1GC, which is also designed to achieve low pause time goals and has the advantage that it does not suffer from fragmentation, such as CMS, and therefore is less likely to experience parallel failures that lead to single - The demanded stop of the world collection.

So try both and measure.

See also: Oracle Java 8 GC Configuration Guides

+9
source

So far, this option has not completely deprecated Oracle in the newer version. We could use this by applying the following jvm options:

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

The later 2 parameters are intended for registration of actions of GC.

+2
source

All Articles