Java Runtime Options
The Java runtime is a complex beast – and it has to be since it runs officially on seven platforms and unofficially on many more. Give this, it is normal that there are many knobs and dials to control how things function. The more well known ones are:
- -Xmx for the maximum heap size
- -client and -server for selecting the default set of parameters from classes of defaults
- -XX:MaxPermGen for controlling the permanent generation size
Other than these, it is (very) rarely the case that you need to change the defaults. However, thanks to Java being open source you can see the list of options, their default values and a short explanation directly from the source code. Currently there are almost 800 options in there!
An other way to see the options (but one which doesn’t display the explanations unfortunately) is the following command:
java -XX:+UnlockDiagnosticVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version
These options are well worth studying. Not for tweaking them (since there is a wealth of testing behind the defaults the extent of which would be very hard to replicate), but rather to understand the different functionalities offered by the JVM (for example why you might not see stacktraces in exceptions).
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
Kuba Kubrynski replied on Mon, 2012/12/31 - 5:39am
Big misunderstood - server/client flags cannot be treated as "sets of parameters" - the primary task is to switch to desired JIT's version.
Sundaresan replied on Mon, 2012/12/31 - 11:04am
Oracle's documentation provides a good overview of the VM options available.
Vladislav Pernin replied on Wed, 2013/01/02 - 3:33pm