Reputation: 315
I've observed "Full GC (System)" messages being written to my logs every 60 minutes. When I do this:
jstat -gccause {pid} 5s
I see that this is coming from explicit calls to System.gc(). I'm trying to track down what code is calling System.gc(), as I suspect that this is happening in one of my dependencies, not my own code.
I do realize I can disable explicit GC calls with -XX:-DisableExplicitGC, but I need to figure out where the calls are coming from. I have read here and here that this guy was able to change the Runtime class to log the stack trace when gc() is called. But I'm not clear on how to do this. Can someone point me in the right direction?
Upvotes: 3
Views: 378
Reputation: 1215
Is your application accessed by/accessing other application via RMI ? Using Remote Method Invocation, you will run into RMI's Distributed Garbage Collection (DGC), which is basically this : A call to System.gc() is periodically made by RMI.
For the client, a Full GC is triggered once every ${sun.rmi.dgc.client.gcInterval}
ms.
For the server, a Full GC is triggered once every ${sun.rmi.dgc.server.gcInterval}
ms.
The default value for these interval are different depending on the version of the JDK. It used to be once per minute (yeah...) but has been changed to once per 30 minutes. You may have different values if you have set these environment variables, for instance, once per hour if your have set -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
.
Source : http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#other_considerations
Upvotes: 0
Reputation: 4307
Maybe the simplest way to get code which call gc() is putting you app code in IDE(eclipse or idea..) download all source(if using maven manage you lib, it maybe simple) and the find the reference of System.gc() or Runtime.getRuntime.gc().
Upvotes: 0
Reputation: 5883
Get the source code for Runtime.java, and add code to the gc() method:
try {
throw new Exception("Who is the GC culprit?");
} catch (Exception e) {
e.printStackTrace();
}
After you compile the class, update rt.jar with the new class file.
Upvotes: 2