HotSpot JVM选项/jmap输出 [英] HotSpot JVM options/jmap output

查看:101
本文介绍了HotSpot JVM选项/jmap输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用以下配置在Hotspot VM上运行Java应用程序时: -Xms2048m -Xmx2048m jmap 输出:

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

但是当我添加另一个jvm选项 -Xmn500m 时, jmap 输出看起来是合理的,即,容量严格遵守公式

But when I add another jvm option -Xmn500m, the jmap outputs seems reasonable, i.e. 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)

当我这样做时:

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

很明显,这是 8 .但是在测试时,它的表现更像是 6 (我无法重现您使用 jdk-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).

-Xmx2048m -Xms2048m

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

也就是说:

512/85 = 6

512/85 = 6

在我使用相同的 -Xmx2048m -Xms2048m 运行相同的代码后,但是添加默认值: -XX:SurvivorRatio = 8 ;输出为:

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

546.5 / 68 = 8.

您要设置的 -Xmn 也是如此.这很奇怪!我没有更改SurvivorRatio的值-它仍然是默认值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.

似乎内部有一些检查是否设置了与SurvivorRatio的计算有关的标志并应用了不同的策略(我希望我知道这些的内在因素,但没有运气).

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).

还有 boy!我试图找到这些东西.我确实发现了某事暗示了这一点,但没有直接给出答案,例如

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" .

在本地hotspot来源内部,仍然无法暗示正在发生的所有结果.

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

我目前唯一的逻辑解释是,除非指定了 SurvivorRatio相关的任何参数,否则;将选择默认值(不一定是java -XX:+PrintFlagsFinal报告的默认值),而是中间的某个值,接近该值.如果是这种情况,则应在文档中明确指定;否则,在我的世界中,这是一个很小的文档错误.

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.

这篇关于HotSpot JVM选项/jmap输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆