Profile Image
vishnupriya

What is Print Command Line Flags: -XX:+PrintCommandLineFlags?

What is Print Command Line Flags: -XX:+PrintCommandLineFlags? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xx-printcommandlineflags

  • x-printcommandlineflags

  • Print Command Line Flags

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

Usage:


• -XX:+PrintCommandLineFlags


Description:


The -XX:+PrintCommandLineFlags flag enables printing the values of the most
useful flags controlling the heap size and garbage collection, along with their
values. The values shown will either be the defaults provided by the JVM
installation, or the values as supplied by command line flags.


For example:


java -XX:+PrintCommandLineFlags -version


Prints (on an example device with 16 GB of RAM):


-XX:ConcGCThreads=2 -XX:G1ConcRefinementThreads=8 -XX:GCDrainStackTargetSize=64
-XX:InitialHeapSize=268435456 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=4294967296
-XX:MinHeapSize=6815736 -XX:+PrintCommandLineFlags
-XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache
-XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC

 

If the maximum heap size is set to 8 GB using the -Xmx option:


java -Xmx8g -XX:+PrintCommandLineFlags -version


then the output would reflect the value specified:

 

-XX:ConcGCThreads=2 -XX:G1ConcRefinementThreads=8 -XX:GCDrainStackTargetSize=64
-XX:InitialHeapSize=268435456 -XX:MarkStackSize=4194304 -XX:MaxHeapSize=8589934592
-XX:MinHeapSize=6815736 -XX:+PrintCommandLineFlags
-XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache
-XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC

 

The flags printed by -XX:+PrintCommandLineFlags are selected as the most
commonly used flags for tuning the performance of the JVM, however there are
many more flags not printed by this command. To see the complete set of flags
along with their values, use the -XX:+PrintFlagsFinal flag in combination with
-XX:+UnlockDiagnosticVMOptions and -XX:+UnlockExperimentalVMOptions.

 

Default Value:


-XX:+PrintCommandLineFlags is off by default, i.e. command line flags are not
printed.


Errors:


None

 

Arguments Related to -XX:+PrintCommandLineFlags:


TODO: link to -XX:+PrintFlagsFinal


Related Posts:


None


NOTE:


If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your
insights will help the entire 10+ million java developer community to develop
one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xx-printcommandlineflags

  • x-printcommandlineflags

  • Print Command Line Flags