为什么jvm中的“ from space”和“ to space”不相等

时间:2019-04-10 09:57:46

标签: java jvm jvm-hotspot

  • 环境:jdk8u101
  • os:centos6
  • 描述:“从空间”和“至空间”不等于堆的伊甸园。在我看来,“从太空”和“到太空”使用复制算法,它们的空间将始终保持相等。
  • 有人可以帮助我吗?
  • 我无法粘贴屏幕截图,所以我将主要数据粘贴在下面

[root@05c46b9d1fc1 /]# jmap -heap 1
Attaching to process ID 1, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.101-b13

using thread-local object allocation.
Parallel GC with 33 thread(s)
Heap Configuration:
   MinHeapFreeRatio         = 0
   MaxHeapFreeRatio         = 100
   MaxHeapSize              = 4294967296 (4096.0MB)
   NewSize                  = 357564416 (341.0MB)
   MaxNewSize               = 1431306240 (1365.0MB)
   OldSize                  = 716177408 (683.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 = 342360064 (326.5MB)
   used     = 251910632 (240.2406997680664MB)
   free     = 90449432 (86.2593002319336MB)
   73.58061248639093% used
From Space:
   capacity = 23068672 (22.0MB)
   used     = 0 (0.0MB)
   free     = 23068672 (22.0MB)
   0.0% used
To Space:
   capacity = 44564480 (42.5MB)
   used     = 0 (0.0MB)
   free     = 44564480 (42.5MB)
   0.0% used
PS Old Generation
   capacity = 763363328 (728.0MB)
   used     = 26507512 (25.27953338623047MB)
   free     = 736855816 (702.7204666137695MB)
   3.47246337722946% used

1 个答案:

答案 0 :(得分:0)

假设堆在增长(因为工作集在增长),那么JVM将使新空间大小与旧空间大小的比率保持不变。为此,它需要分配比“来自”空间大的“至”空间。

要详细了解JVM如何计算空间大小,我建议您下载并仔细研究您想要的OpenJDK的特定版本(发行版和补丁程序)的源代码。了解。