vendredi 26 février 2010

Get a complete list of all possible JVM options

To get a reliable list of all config options for a given Sun JVM, look directly into the compiled code. For example :

$ strings $JAVA_HOME/jre/lib/amd64/server/libjvm.so | grep -B646 assert_null$ | grep -v '{' | grep -v '&' | grep -v '/' | grep -v '%' | grep -v assert_null

(on one line)
Do you know all 646 options ?

EDIT : it is also possible to get the default value and computed value for each option using the jinfo tool shipped with the JDK. First the need the id of the vm from which you want the options. it is easy, just run jps and choose the appropriate id (we'll call id $LVMID)

It looks like a few options are available but not extracted from libjvm.so, but can be found in deploy.jar :

MaxDirectMemorySize
MaxHeapFreeRatio
MaxInlineSize
MinHeapFreeRatio
NewSize
PermSize
ThreadStackSize
CompileThreshold

You can add these well known options to the list above for the next part :

Using the list we got above (let's say we've redirected the list to a file named 6_0_18_complete_options_list , it is then possible to print the (almost) complete list of the options with their default, computed, or overriden value using :



$ for i in `cat 6_0_18_complete_options_list` ; do jinfo -flag ${i} $LVMID | tee -a /tmp/default_computed_vm_options ; done ;

All the values will be written to default_computed_vm_options, with the numeric value , or a + / - in front of the option if it's a boolean. very instructive way to find out the defaults for your specific platform


Lots of interesting stuff in there for JVM geeks :)
I hope you're not lactose intolerant because what you will find is legen....da(i)ry