I'm still investigating issues I have with GC tuning (see prior question), which involves lots of reading and experimentation.
Sun Java5+ JVMs attempt to automatically select the optimal GC strategy and parameters based on their environment, which is great, but I can't figure out how to query the running JVM to find out what those parameters are.
Ideally, I'd like to see what values of the various GC-related -XX options are being used, as selected automatically by the VM. If I had that, I could have a baseline to begin tweaking.
Anyone know to recover these values from a running VM?
-XX:+PrintCommandLineFlags Prints flags passed on command line or configured by the ergonomics (auto-sizing) features.
-XX:+PrintFlagsInitial Dumps ALL the default flags and values.
-XX:+PrintFlagsFinal Dumps ALL the flags after processing command line and ergonomics.
So I think the latter will do for you, just add it to your command line script.
If you're looking for a quick and easy human-readable tool, jconsole might be your friend here. Specifically, I'm looking at the "VM Summary" tab on my currently running FindBugs process and I see these details:
Obviously, jvisualvm will give you related details but it doesn't seem to be quite as tightly focused on your specific needs (i.e., quickly readable details on the garbage collector).
It's not usually straightforward to deduce the exact heap configuration just from the command line flags supplied.
If your need is to know the heap configuration and you are in a non-Windows environment you can use
jmap -heap
like explained in this blog entry.Here is a sample of the information provided:
Check out the HotSpotDiagnosticMBean
The following example will print out the value of an option as well as whether the value is DEFAULT or VM_CREATION:
You can use JMX for that. Kick off JConsole, and it should be displayed under the VM Summary tab. It should display all the arguments that have been passed to the JVM.
To do it programatically, you can refer to another SO answer: How to get vm arguments from inside of java application?