开发者

Find System.gc() in compiled libraries

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 trac开发者_如何学编程k 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] 


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.

This will find calls anywhere in the system including the JDK.

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


I would use FindBugs. It's a fabulous tool, and it have a built-in rule for explicit Garbage COllection calls.


Use profilers. Any of the modern profiler would help you find this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜