问题描述
我在我们的gc-log中看到明确的gc调用(见下文)。我可以用-XX:+ DisableExplicitGC删除调用,但我真的想知道哪个代码/库调用了 System.gc()
?
I see explicit gc invocations in our gc-log (see below). I am able to remove invocations with -XX:+DisableExplicitGC but I really want to know which code/library is calling System.gc()
?
关于如何追踪它的任何提示?
Any hints on how to track it down?
2011-05-30T12:21:48.230+0200: 1.672: [Full GC (System) 1.672: [CMS: 0K->2227K(2868864K), 0.0862299 secs] 62069K->2227K(3118080K), [CMS Perm : 12899K->12893K(409600K)], 0.0863197 secs] [Times: user=0.06 sys=0.03, real=0.09 secs]
推荐答案
我创建了一个System类的定制版本,每当System.gc()被调用时,一个文件堆栈跟踪。这将允许您跟踪所有被调用的地方。
I created a custom version of the System class which writes to a file a stack trace whenever System.gc() is called. This will allow you to trace all the places it is called.
这将在包括JDK的系统中的任何地方找到调用。
This will find calls anywhere in the system including the JDK.
您调用System.gc()的一个位置位于RMI模块中,以帮助查找丢弃的远程对象。您可以减少使用
One place you get calls to System.gc() is in the RMI module to help find discarded remote objects. You can decrease how often it will call a full GC with
-Dsun.rmi.dgc.server.gcInterval=86400000
-Dsun.rmi.dgc.client.gcInterval=86400000
这篇关于在编译的库中查找System.gc()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!