In the context of an in-memory database, we are using off-heap memory in conjunction to the G1 collector of hotspot.
在内存数据库的上下文中,我们将使用堆外存储器连接到hotspot的G1收集器。
However, when off-heap memory usage reaches MaxDirectMemorySize, a full GC is triggered by the JDK code using System.gc()
. This causes a long and painful stop the world GC, that also seem to put all the current live set in the old gen, bypassing the survivor (and thus increasing nepotism issues). This does not happen when setting -XX:+ExplicitGCInvokesConcurrent
: the GC is much faster and respects the survivors.
但是,当非堆内存使用达到MaxDirectMemorySize时,使用System.gc()的JDK代码触发一个完整的GC。这导致了一个漫长而痛苦的停止世界GC的过程,似乎也把所有当前的生活都集中在了老gen身上,绕过了幸存者(从而增加了任人犯的问题)。这在设置-XX:+ itgcinvokesconcurrent: GC要快得多,尊重幸存者时不会发生。
Since System.gc()
is something used internally by the JDK, why isn't this option on by the default in hotspot? Does this flag induce theoritical or practical issues? Or is just for compatibility reasons? Does anybody has experience of using this option in a production environment, and encountered issues with it?
因为System.gc()是JDK内部使用的东西,为什么在hotspot中不使用这个选项呢?这面旗帜会引起理论性的或实际的问题吗?或者只是出于兼容性的原因?是否有人在生产环境中使用此选项,并遇到问题?
1 个解决方案
#1
1
From what it seems, the JDK folks have not answered this question yet either (see the comment of Charlie Hunt on JDK-8071770).
从表面上看,JDK的人们还没有回答这个问题(参见JDK-8071770上关于Charlie Hunt的评论)。
The only drawback that I found about using this option so far is the fact that by default a concurrent GC does not unload classes (see JDK-6541037). But if this is your issue, you can use -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses instead.
到目前为止,我发现使用这个选项的唯一缺点是,默认情况下,并发GC不会卸载类(参见JDK-6541037)。但是如果这是您的问题,您可以使用-XX:+ itgcinvokesconcurrentandunloadsclass代替。
Edit 2017: A specific ticket with the same question has been open for jdk10: JDK-8160392
编辑2017:针对jdk10: JDK-8160392,有一个相同问题的特定票。
#1
1
From what it seems, the JDK folks have not answered this question yet either (see the comment of Charlie Hunt on JDK-8071770).
从表面上看,JDK的人们还没有回答这个问题(参见JDK-8071770上关于Charlie Hunt的评论)。
The only drawback that I found about using this option so far is the fact that by default a concurrent GC does not unload classes (see JDK-6541037). But if this is your issue, you can use -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses instead.
到目前为止,我发现使用这个选项的唯一缺点是,默认情况下,并发GC不会卸载类(参见JDK-6541037)。但是如果这是您的问题,您可以使用-XX:+ itgcinvokesconcurrentandunloadsclass代替。
Edit 2017: A specific ticket with the same question has been open for jdk10: JDK-8160392
编辑2017:针对jdk10: JDK-8160392,有一个相同问题的特定票。