IN-Decent

Re-decentralizing internet with free software

Java Configuration Option to Get All Flags and Its Values That Will Be Used by JVM

Posted at — Jul 11, 2020

When a Java Virtual Machine is started without any command-line options it is difficult to know the default memory heap size settings that will be used and values of other configuration flags as well as it is calculated dynamically based on the host system where a Java process is running.

There is a special JVM configuration flag -XX:+PrintFlagsFinal which when used Java virtual machine will output all the flags and its values that will be used by JVM. This is useful in situations to find the default values that will be used, when those values are not explicitly configured.

Below command can be used to find the initial heap size, maximum heap size and the garbage collector that will be used by JVM in my host.

java -XX:+PrintFlagsFinal -version | grep -iE 'initialheapsize|maxheapsize|use.*GC '
   size_t InitialHeapSize                          = 50331648                                  {product} {ergonomic}
   size_t MaxHeapSize                              = 775946240                                 {product} {ergonomic}
     bool UseAdaptiveSizePolicyWithSystemGC        = false                                     {product} {default}
     bool UseConcMarkSweepGC                       = false                                     {product} {default}
     bool UseG1GC                                  = true                                      {product} {ergonomic}
     bool UseMaximumCompactionOnSystemGC           = true                                      {product} {default}
     bool UseParallelGC                            = false                                     {product} {default}
     bool UseParallelOldGC                         = false                                     {product} {default}
     bool UseSerialGC                              = false                                     {product} {default}
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Debian-3)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Debian-3, mixed mode, sharing)

References:

  1. HotSpot JVM Options Displayed: -XX:+PrintFlagsInitial and -XX:+PrintFlagsFinal
  2. Inspecting HotSpot JVM Options
  3. Oracle documentation listing all JVM flags and its description