Search code examples
jvmjvm-arguments

Why is output of MaxHeapSze different when calling -XX:+PrintFlagsFinal and -XX:+PrintCommandLineFlags?


Just like the question, when I run the program with JVM option -XX+PrintFlagsFinal, I can see the printed MaxHeapSize as below:

 bool MaxFDLimit                                = true            {product}
uintx MaxGCMinorPauseMillis                     = 4294967295      {product}
uintx MaxGCPauseMillis                          = 4294967295      {product}
uintx MaxHeapFreeRatio                          = 70              {product}
**uintx MaxHeapSize                              := 1044381696      {product}**
 intx MaxInlineLevel                            = 9               {product}
 intx MaxInlineSize                             = 35              {product}
 intx MaxJavaStackTraceDepth                    = 1024            {product}

While when I run the same program with JVM option -XX+PrintCommandLineFlags, I can see the MaxHeapSize as :

-XX:InitialHeapSize=65192896 **-XX:MaxHeapSize=1043086336** -XX:+PrintCommandLineFlags -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC 

Can you tell me why these two are different? I thought they should be the same.


Solution

  • The actual heap size may differ from what the user specified in the command line due to alignment and ergonomics adjustments. By default, the heap is 2MB aligned (see collectorPolicy.cpp).

    1044381696 is the final heap size after 2MB-alignment of 1043086336.