Thursday, February 9, 2023

Print All JVM Flags

This article was originally posted on JRoller on the October 22nd, 2011

 I just discovered this very interesting post by Zahid Qureshi. He tells us about a JVM flag, that I never heard about before, that displays all the JVM flags, their default value, and the values that were set by your own settings. With the following line, you get a list of over 700 flags in the JDK6:

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

The "-version" flag is just here to avoid an error message. The "UnlockDiagnosticVMOptions" unlocks several JVM options.

I tried it with the JDK7, to confirm that G1 GC is not triggered by default:

bool UseG1GC = false

 These flags still exist in current Java versions, although the value of the UseG1GC flag is now set to true by default. Also, in the original comments, someone posted another flag that unlocks even more options: "-XX:+UnlockExperimentalVMOptions".

No comments:

Post a Comment