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

1

2

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.

Helicline answered 15/6, 2014 at 6:59 Comment(0)
S
6

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.

Sherlocke answered 15/6, 2014 at 9:27 Comment(2)
Thanks. But (1044381696-1043086336) is around 1.23M, not 2M. What do you think about it?Helicline
@Helicline 1043086336 is not 2M-aligned, i.e. X / (2*1024*1024) = 497.38 - fractional. The nearest multiple of 2M to it is 1044381696: X / (2*1024*1024) = 498.Sherlocke

© 2022 - 2024 — McMap. All rights reserved.