简体   繁体   中英

HotSpot JVM options/jmap output

When I running my java application on Hotspot VM using following configuration: -Xms2048m , -Xmx2048m , the jmap outputs:

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 2147483648 (2048.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 85983232 (82.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 706740224 (674.0MB)
   used     = 364788568 (347.88948822021484MB)
   free     = 341951656 (326.11051177978516MB)
   51.61565107124849% used
From Space:
   capacity = 4587520 (4.375MB)
   used     = 1900560 (1.8125152587890625MB)
   free     = 2686960 (2.5624847412109375MB)
   41.428920200892854% used
To Space:
   capacity = 4456448 (4.25MB)
   used     = 0 (0.0MB)
   free     = 4456448 (4.25MB)
   0.0% used
   ...

What makes me confused is why the capacity of eden space and two survivor space doesn't obey the formula

eden/(s0+s1) = SurvivorRatio

But when I add another jvm option -Xmn500m , the jmap outputs seems reasonable, ie the capacity obeys the formula strictly

I wish this would get a bit more attention... Indeed you are right (this is not an answer - but too long for a comment)

When I do:

 java -XX:+PrintFlagsFinal | grep SurvivorRatio
      uintx InitialSurvivorRatio                     = 8

Clearly this is 8 . But when testing it's acting more like a 6 (I can't reproduce your HUGE difference that you are seeing with jdk-8 ).

Here is the relevant parts when running with -Xmx2048m -Xms2048m

 PS Young Generation
 Eden Space:
 capacity = 537395200 (512.5MB)
 ....
 From Space:
 capacity = 89128960 (85.0MB)
 ....
 To Space:
 capacity = 89128960 (85.0MB)

That is:

512/85 = 6

As soon as I ran the same code with the same -Xmx2048m -Xms2048m , but add the default value : -XX:SurvivorRatio=8 ; the output is:

 PS Young Generation
 Eden Space:
 capacity = 573046784 (546.5MB)
 ....
 From Space:
 capacity = 71303168 (68.0MB)
 ....
 To Space:
 capacity = 71303168 (68.0MB)

546.5 / 68 = 8.

The same is true for -Xmn - that you are setting. And this is weird! I have not changed the value of SurvivorRatio - it is still the same default 8.

It seems that internally there are some checks whether flags related to the computation of SurvivorRatio are being set and different policies applied(I wish I knew the intrinsics of these, but no luck).

And boy! did I try to find these. I did find something that hints towards that, but not directly an answer, like this or this (especially the comment). I did a :

  grep -R "SurvivorRatio" .

inside the hotspot sources locally and still no hint in all the results of what is going on.


The only logical explanation I have at this point in time, is that unless specified any parameter related to SurvivorRatio ; a default value will be chosen (that is not necessarily the one reported by java -XX:+PrintFlagsFinal ), but something in the middle, something close to that. If this is the case, then it should clearly be specified in the documentation ; otherwise in my world this is a tiny documentation bug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM