如何在Java GC中自适应地调整旧区域的大小?

log*_*nor 8 java garbage-collection

为了调优Java 6(1.6.0_23)GC,我-XX:+UseParallelOldGC一起使用

-XX:+PrintTenuringDistribution
-XX:+UseAdaptiveSizePolicy
-XX:+UseAdaptiveGCBoundary
Run Code Online (Sandbox Code Playgroud)

我的目标是让GC计算旧区域和新区域之间的最佳比率.然而,visualgc(jvmstat 3.0)显示,虽然伊甸园和幸存者之间的比例根据我的工作量进行了修改,但旧区域仍然(绝望地)保持其初始大小,由newRatio(在我的情况下为2)固定.

我的设置或期望有什么问题?

在我的屏幕上,在19个系列之后,visualgc显示旧Gen一直低于500米,而旧Gen的保留和承诺尺寸等于624米.我已设置新尺寸30米和MaxNewSize 300米,但是这不会改变任何东西:NewRatio似乎untangible ... PrintAdaptiveSizePolicy只谈到的幸存者.

+ UseAdaptiveGCBoundary没有任何变化:问题的关键是,visualgc中的"预留空间"菜单中不显示旧创空间什么...我已经在使用-XX也tryed.

这是一些日志 -XX:+PrintTenuringDistribution -XX:+PrintGCDetails

有一个完整的gc,以及堆的最终打印......似乎终身分布也是乱码......

Desired survivor size 119275520 bytes, new threshold 1 (max 15)
[PSYoungGen: 182096K->66576K(233024K)] 681978K->631994K(932096K), 0.2582390 secs] [Times: user=0.29 sys=0.00, real=0.26 secs]
116.431: [GC
Desired survivor size 119275520 bytes, new threshold 1 (max 15)
[PSYoungGen: 183120K->39952K(233024K)] 748538K->670910K(932096K), 0.1578620 secs] [Times: user=0.29 sys=0.00, real=0.16 secs]
116.589: [Full GC [PSYoungGen: 39952K->0K(233024K)] [ParOldGen: 630958K->310429K(699072K)] 670910K->310429K(932096K) [PSPermGen: 21973K->21973K(30592K)], 1.3326720 secs] [Times: user=1.79 sys=0.01, real=1.33 secs]
118.050: [GC
Desired survivor size 119275520 bytes, new threshold 1 (max 15)
[PSYoungGen: 116544K->18448K(233024K)] 426973K->328877K(932096K), 0.0745320 secs] [Times: user=0.14 sys=0.00, real=0.08 secs]
118.234: [GC
Desired survivor size 119275520 bytes, new threshold 1 (max 15)
[PSYoungGen: 134992K->24592K(233024K)] 445421K->351409K(932096K), 0.1290960 secs] [Times: user=0.14 sys=0.00, real=0.13 secs]
118.526: [GC
Desired survivor size 114884608 bytes, new threshold 1 (max 15)
[PSYoungGen: 141136K->36880K(237312K)] 467953K->380085K(936384K), 0.1187320 secs] [Times: user=0.21 sys=0.00, real=0.12 secs]
118.759: [GC
Desired survivor size 108593152 bytes, new threshold 1 (max 15)
[PSYoungGen: 142446K->40976K(233024K)] 485652K->416957K(932096K), 0.1153230 secs] [Times: user=0.23 sys=0.00, real=0.12 secs]
Heap
PSYoungGen total 233024K, used 97957K (0xb3a40000, 0x9e4f0000, 0x9e4f0000]
eden space 120832K, 47% used [0x9e4f0000,0xa1c95668,0xa5af0000)
from space 112192K, 36% used [0xa5af0000,0xa82f4020,0xac880000)
to space 106048K, 0% used [0xad2b0000,0xad2b0000,0xb3a40000)
ParOldGen total 699072K, used 375981K [0x73a40000, 0x9e4f0000, 0x9e4f0000)
object space 699072K, 53% used [0x73a40000,0x8a96b730,0x9e4f0000)
PSPermGen total 30592K, used 21981K [0x6fa40000, 0x71820000, 0x73a40000)
object space 30592K, 71% used [0x6fa40000,0x70fb7668,0x71820000)
Run Code Online (Sandbox Code Playgroud)

Ste*_*n C 3

如何在 Java GC 中自适应调整旧区域的大小?

我认为这是不可能的。GC 有一组有限的“调谐旋钮”,我看不出有哪个可以为您做到这一点。我的感觉是你“想太多”这个问题。

参考:

如果这个答案不够好,那么您的选择就相当有限:

  • 如果您通过适当的渠道并准备花一些钱,您可能会从 Oracle 调优专家那里得到一些帮助。

  • 如果您有时间和耐心,您可以尝试了解 OpenJDK 代码库中的 GC 源代码。