How to monitor garbage collection to see what is GC'd?

I have a huge Java app (Running Jdk7 64Bit, Weblogic 12). Running the application without anyone calling it - aka just idling. I can see every 3-4 minutes there is a 300Mb spike and then it is garbage collected using visual vm.

在这里输入图像描述

I took several stack traces and nothing is busy at the time when it was taken. We also make use of EHCache and added logging to log the results. Once the app is up and running I cannot see anything in the logs (while it is idling) but still there is this 300mb garbage collection that takes place.

Taking a heap dump when the used space is low and 300mb afterwards do not show much of a difference using eclipse memory analyser with the memory allocations looking the same:

在这里输入图像描述

Is there a way to see what is being garbage collected? And I do understand that there will be constant collection but is 300mb ok?


What you are seeing is the impact of monitoring to your application, given that it's implemented in Java. I would suggest that you add -XX:+PrintGCDetails to your commandline, and check how often GCs happen with and without monitoring.

And yes, that rate of garbage (300MB/5min) is normal for JMX. Also, how huge is your application? More than 32 GB RAM?


Your memory behavior is not problematic. Even if your application is idle, many things are going on, causing the memory allocation you are observing. I presume you are monitoring total heap including young generation. Thus every object allocated will show up on your graphs. A young GC every 3-4 minutes absolutely normal and takes only a few ms each time.

So I would switch to monitoring old generation only, and you'll have a very flat line and no GCs at all.

链接地址: http://www.djcxy.com/p/81432.html

上一篇: 内存不足

下一篇: 如何监控垃圾收集以查看GC'd是什么?