What GC parameters is a JVM running with?

Viewed 10299

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?

4 Answers

-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:

Current heap size: 788,720 kbytes

Maximum heap size: 932,096 kbytes

Committed memory: 923,648 kbytes

Pending finalization: 0 objects

Garbage collector: Name = 'PS MarkSweep', Collections = 324, Total time spent = 12 minutes

Garbage collector: Name = 'PS Scavenge', Collections = 1,132, Total time spent = 1 minute

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).

Related