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.

Naman
  • 27,789
  • 26
  • 218
  • 353
PixelsTech
  • 3,229
  • 1
  • 33
  • 33

1 Answers1

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.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Thanks. But (1044381696-1043086336) is around 1.23M, not 2M. What do you think about it? – PixelsTech Jun 16 '14 at 11:34
  • 1
    @PixelsTech 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. – apangin Jun 16 '14 at 16:56