Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default Full GC interval in Java 8

We noticed a strange behavior on our production server (JavaEE, Wildfly 10). The Java VM do once per hour Full GC although there is still enough memory available.

enter image description here

The VM start parameters are:

-server
-Xms4g
-Xmx8g

The following parameters are not activated:

-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000

So what is the default Full GC interval in Java 8 and how can I configure it to be dynamic?

like image 744
dieter Avatar asked Feb 06 '18 10:02

dieter


1 Answers

You say that

-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000

are not "activated". However, those are the default values for those properties; i.e. the values that you get if you DON'T specify values for the properties.

Reference: Oracle's sun.rmi Properties documentation.

So what is the default Full GC interval in Java 8

See above for the DCG triggered full GCs.

Apart from that, a full GC happens when requested (by a System.gc() call) or when the JVM decides it is necessary. There is no fixed interval if you are not using RMI.

... and how can I configure it to be dynamic?

If you mean, how can you stop RMI from triggering a full GC every hour:

  • One way is to specify (much) larger values for those properties.

  • Another way is to launch the JVM with the -XX:+DisableExplicitGC flag. Note: this will disable all calls to System.gc() not just the calls that RMI's DGC makes. See also: Impact of setting -XX:+DisableExplicitGC when NIO direct buffers are used for some of the problems that this may cause.

  • A third way is to use -XX:+ExplicitGCInvokesConcurrent flag. This reduces the impact of calls to System.gc(), but it will only work with GCs that support concurrent collection; e.g. CMS, G1, ZGC or Shenandoah.

    You can potentially tune other things to reduce the concurrent collectors "stop the world" pauses, but that is beyond the scope of this question.

like image 156
Stephen C Avatar answered Nov 13 '22 05:11

Stephen C