经常遇到各种GC造成的小问题干扰,不搞清楚细节就很烦,所以开始一点点收集信息便于以后排查问题。
1:gc log中显示 Full GC (System) 字样是什么意思。
具体可见下面这篇文章
总结下就是 调用了System.gc()后打印的FullGC log
2:如何查看谁调用了System.gc()
这个可以使用Btrace 中的jstack功能,代码如下
import static com.sun.btrace.BTraceUtils.*; import com.sun.btrace.annotations.*; @BTrace public class Js{ @OnMethod( clazz="java.lang.System", method="gc" ) public static void traceExecute(){ println("System.gc() call ---------------------"); jstack(); } }
3:Full GC(System) 有规律的一分钟一次
这个可能是由于rmi的默认gc策略导致的,见http://docs.oracle.com/javase/1.4.2/docs/guide/rmi/sunrmiproperties.html
sun.rmi.dgc.server.gcInterval
(1.2 and later)
sun.rmi.dgc.client.gcInterval
(1.2 and later)
The default value is 60000 milliseconds (60 seconds).
可以手动添加这个参数到JVM启动中,例如修改为默认一天或者一小时GC一次,不建议直接增加DisableExplicitGC
具体原因可以参见撒迦同学的参数陷阱贴
http://hllvm.group.iteye.com/group/topic/27945 (强力推荐哇可以学习到很多知识)
4:如何分析CMS gc log
https://blogs.oracle.com/poonam/entry/understanding_cms_gc_logs
5:usr sys real 3者的大概含义
http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1
6:Diagnosing a Garbage Collection problem
http://www.oracle.com/technetwork/java/example-141412.html