Java 8 中默认的 Full GC 间隔是多少 [英] What is the default Full GC interval in Java 8
问题描述
我们注意到生产服务器(JavaEE、Wildfly 10)上的一个奇怪行为.尽管仍有足够的可用内存,但 Java VM 每小时执行一次 Full GC.
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.
VM 启动参数为:
-server
-Xms4g
-Xmx8g
以下参数未激活:
-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000
那么 Java 8 中默认的 Full GC 间隔是多少,如何将其配置为动态的?
So what is the default Full GC interval in Java 8 and how can I configure it to be dynamic?
推荐答案
你说
-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.
参考:Oracle 的 sun.rmi 属性 文档.
Reference: Oracle's sun.rmi Properties documentation.
Java 8 中默认的 Full GC 间隔是多少
So what is the default Full GC interval in Java 8
有关 DCG 触发的完整 GC,请参见上文.
See above for the DCG triggered full GCs.
除此之外,当请求(通过 System.gc()
调用)或当 JVM 认为有必要时,会发生完整的 GC.如果您不使用 RMI,则没有固定的时间间隔.
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?
如果你的意思是,你怎么能阻止 RMI 每小时触发一次完整的 GC:
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.
另一种方法是使用 -XX:+DisableExplicitGC
标志启动 JVM.注意:这将禁用对 System.gc()
的所有调用,而不仅仅是 RMI 的 DGC 进行的调用.另请参阅:设置 -XX:+DisableExplicitGC 时的影响NIO 直接缓冲区用于解决这可能导致的一些问题.
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.
第三种方法是使用 -XX:+ExplicitGCInvokesConcurrent
标志.这减少了调用 System.gc()
的影响,但它只适用于支持并发收集的 GC;例如CMS,G1,ZGC 或 Shenandoah.
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.
这篇关于Java 8 中默认的 Full GC 间隔是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!