If you have to choose only one tool to troubleshoot Java memory related issues, you must choose the ‘verbose gc logs’. Verbose GC log has so much information that you can diagnose almost all types of memory issues just by carefully reviewing the data in this file. It is such a valuable tool.
What’s more? The load exerted on the JVM due to verbose GC logging is virtually nothing. So, don’t skimp on enabling verbose gc logs when you need to.
What exactly do the verbose GC logs reveal?
In addition to numerous other metrics, verbose GC logs reveal the following important metrics:
1. GC frequency (how often GC kicks in, both minor and major collections)
2. GC duration (how long each GC cycle takes to finish)
3. Before and After memory utilization of various generations following every GC cycle
Just with the above three metrics, you can pretty much tell what’s going on with the memory
How to enable verbose GC logs ?
Just add the following java command line option
-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
Two important notes:
1. –verbose:gc works for all implementations of JVM (HP, IBM etc). However the other two options are not guaranteed to work for non-Oracle JVMs
2. As usual, Oracle states that the output produced by the above options is subject to change in future releases.
You must restart your application to have the change take effect.
Where does the verbose gc logs go ?
By default, verbose gc collection logs go to the standard out (in case of IBM JVM, native_stderr.log).
However, you can override this by specifying a specific log file using the following options
Next let us look at the step by step instructions to troubleshoot memory issues by analyzing verbose gc logs
Coming up: Troubleshooting GC: Step by Step instructions to analyze verbose GC logs
Previous: Troubleshooting GC: Native Memory issues
Have you seen multiple verbose gc logs on their Websphere 220.127.116.11 env once verbose gc option is enabled?
I have seen about max 10 verbosegc.001 to 010.logs and the size of 21,137kb created on my log directory.
Is this a new behavior with Websphere 9? I used to see the gc information was logged in native_stderr.log with Websphere 8.5.5.x
Does you know how to increase the size of verbose gc log or increase number of verbose gc log, so they don’t get overwritten?
or do you know how to change back to the old behavior writing the gc information to native_stderr.log in a signle file?
Hi Justin, that’s interesting. I have not played with WAS 9.x yet. Is this WebSphere Application Server or WebSphere Portal (or any other WebSphere product) ?
java command line option ? I will also be interested in seeing the current java command line options in place – can you run “ps -ef|grep -i websphere” and check for “verbosegc” string ?
Can you try specifying -Xverbosegclog:
I have an issue when I’m exporting GC logs. I must tell you that I’m new at this, so please don’t mind if I’ve got something wrong.
So, I enter C:\Java\jdk\bin and type the command : java -verbose:GC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps. For some reason, it prints me only Heap part, not the logs.
Can you please tell me what I’m doing wrong?