Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print All JVM Flags

Found an interesting JVM Flag :

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version 

It prints hundreds of various options, I never heard about before. It also prints default values, that helps diagnose JVM behaviors better. Another interesting flag is:

-XX:+UnlockExperimentalVMOptions 

Does anyone knows of any documentation which explains each one of them ?

like image 752
Sachin Bhansali Avatar asked May 07 '12 17:05

Sachin Bhansali


People also ask

How can I see JVM arguments?

Double click [your application] (pid [n]). On the right side, there will be inspection contents in a tab for the application. In the middle of the Overview tab, you will see the JVM arguments for the application.

Where can I find JVM options?

options configuration file. The default location of this file is config/jvm. options (when installing from the tar or zip distributions) and /etc/elasticsearch/jvm. options (when installing from the Debian or RPM packages).


2 Answers

Do not miss also -XX:+JVMCIPrintProperties for Graal JIT options.

Before dive into sources you can skim over following extracts and find suitable option faster:

https://chriswhocodes.com/ (OracleJDK 6/7/8/9/10/11/12, OpenJDK 8/9/10/11, Graal CE/EE, OpenJ9, Zing)

http://jvm-options.tech.xebia.fr/

http://www.pingtimeout.fr/2012/05/jvm-options-complete-reference.html

http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html

like image 144
Andriy Plokhotnyuk Avatar answered Oct 11 '22 11:10

Andriy Plokhotnyuk


The best documentation I've found is the source.

I've used this SO Q&A to create a debug build. With this debug build, you can run java -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+PrintFlagsFinal -XX:+PrintFlagsWithComments -version.

From the directory with the sources, you could execute (assuming you are using Linux, Cygwin or the like):

grep -FR 'UnlockExperimentalVMOptions' hotspot/ 

Or, the following (which only looks at *.cpp and *.hpp files):

find hotspot/ -name '*.[ch]pp' -exec grep -F 'UnlockExperimentalVMOptions' {} + 

Then look at the source files. Probably the best reason why there is no one document that describes all options is that some of these options are better left to those who really understand the JVM and the best way to do that is to become intimately familiar with the source code.

So, in the words (almost) of a great master, use the source!

like image 32
Dan Cruz Avatar answered Oct 11 '22 12:10

Dan Cruz