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
Answer from Andriy Plokhotnyuk on Stack OverflowDo 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
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!
Looks like: java -XX:+PrintFlagsFinal -version | grep -iE 'MaxHeapSize' starts a Java process and prints out the settings on it. It does not print the JVM settings from the running Java process.
This worked for me: jinfo <pid-of-running-java-process> | grep 'HeapSize'. This printed:
Non-default VM flags: ... -XX:InitialHeapSize=12884901888 -XX:MaxHeapSize=12884901888 ...
Am I looking at the wrong place for the max heap size the process can use?
Yes, you are looking at the wrong place. As @Aishwar points out, running $java -version creates a new Java process. You could :
add the PrintFlagsFinal flag to your servers Java options and read the log file, or simply attach to your java process with a tool like jinfo or JVisualVM and inspect the usage.