I have a project in Netbeans that I am profiling (using Java 7). What I am looking for is, upon a garbage collection, how much memory from the Eden space is going into the Survivor spaces, and if there is any memory overflowing into the Tenured space. On top of that, I am looking for how the Tenured space is growing in size over time.
I print GC stats but I only get info like this:
2339.967: [GC 2339.967: [ParNew: 66213K->4522K(69376K), 0.0161101 secs] 284589K->223320K(369484K), 0.0161685 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
2344.543: [GC 2344.543: [ParNew: 66218K->4520K(69376K), 0.0161084 secs] 285016K->223739K(369484K), 0.0161647 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
2349.118: [GC 2349.118: [ParNew: 66216K->4519K(69376K), 0.0159046 secs] 285435K->224159K(369484K), 0.0159587 secs] [Times: user=0.03 sys=0.00, real=0.02 secs]
Anyone know of a way to figure out the information I am looking for?
Thanks!
In Java, garbage collection happens automatically during the lifetime of a program. This eliminates the need to de-allocate memory and therefore avoids memory leaks. Java Garbage Collection is the process by which Java programs perform automatic memory management.
The easy way to monitor Heap usage is by using a commercial APM (Application Performance management tool) such as CA Wily APM, AppDynamics, New Relic, Riverbed, etc. APM tools not only monitor the heap usage, but you can also configure the tool to Alert you when Heap usage is not normal.
Once the web container has successfully restarted, there should be a GC log file located in the directory specified in the file: option. On Microsoft® Windows® systems: You should enable GC logging by specifying CATALINA_OPTS settings in the setenv. bat file (typically located in the \tomcat\bin\ directory).
For modern computer (multiple cpus, big memory), JVM will detect it as server machine, and use Parallel GC by default, unless you specify which gc to use via JVM flags explicitly.
Here are some useful GC flags:
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintClassHistogram
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintTenuringDistribution should give you what you are looking for.
Oracle's JDK comes standard now with jvisualvm
which is a free profiler. It will show you what's eating up memory, cpu, threads, network time, db access, etc. Yes, it even shows GC time and a bunch of other goodies about GC in general.
Best part, it's free! (and it may already be installed on your system if you have Oracle JDK)
http://www.youtube.com/watch?v=dUQqmnmCBbg
http://docs.oracle.com/javase/6/docs/technotes/tools/share/jvisualvm.html
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