Java eden空间不大于s0空间的8倍

时间:2018-12-08 11:01:53

标签: garbage-collection jvm

根据oracle的doc,SurvivorRatio的默认参数值为8,这意味着每个幸存者空间将是eden空间的八分之一。 但在我的应用程序中不起作用

$ jmap -heap 48865
Attaching to process ID 48865, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.45-b02

using thread-local object allocation.
Parallel GC with 8 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 0
   MaxHeapFreeRatio         = 100
   MaxHeapSize              = 4294967296 (4096.0MB)
   NewSize                  = 89128960 (85.0MB)
   MaxNewSize               = 1431306240 (1365.0MB)
   OldSize                  = 179306496 (171.0MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 67108864 (64.0MB)
   used     = 64519920 (61.53099060058594MB)
   free     = 2588944 (2.4690093994140625MB)
   96.14217281341553% used
From Space:
   capacity = 11010048 (10.5MB)
   used     = 0 (0.0MB)
   free     = 11010048 (10.5MB)
   0.0% used
To Space:
   capacity = 11010048 (10.5MB)
   used     = 0 (0.0MB)
   free     = 11010048 (10.5MB)
   0.0% used
PS Old Generation
   capacity = 179306496 (171.0MB)
   used     = 0 (0.0MB)
   free     = 179306496 (171.0MB)
   0.0% used

7552 interned Strings occupying 605288 bytes.

但是在VisualVM中,eden空间为1.332G,S0为455M,eden仅比S0大3倍,而不是8倍。

enter image description here

1 个答案:

答案 0 :(得分:0)

您既没有禁用-XX:-UseAdaptiveSizePolicy,也没有设置-Xms等于-Xmx,因此JVM在运行时可以自由地调整堆生成(和幸存空间)的大小。在这种情况下,估计的最大Survior大小为

MaxSurvivor = NewGen / MinSurvivorRatio

默认为-XX:MinSurvivorRatio=3。注意:这是估计的最大值,而不是实际大小。

另请参阅this answer