I'd like to know how to get the time spent in GC. I think it is possible because newrelic provides this information on jvm monitoring. Thanks
For hotspot jvm start jvm with -XX:+PrintGCDetails
and it will start logging gc events which includes time spent
if you want to redirect it to file
-Xloggc:/home/someuser/app/logs/jvm/gc.log -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails
http://www.oracle.com/technetwork/java/javase/community/vmoptions-jsp-140102.html
If you want to capture the information in your program, then you could do it using MXBeans. like
List<GarbageCollectorMXBean> list = ManagementFactory
.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean bean : list) {
System.out.println(bean.getCollectionTime());
}
More Information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With