gpt4 book ai didi

Java 垃圾收集器 : How is "Desired Survivor Size" calculated?

转载 作者:搜寻专家 更新时间:2023-11-01 03:37:37 24 4
gpt4 key购买 nike

我在 Solaris 上使用 HotSpot JVM 1.6.0_45。以下是我关于堆的选项:

-Xms8G
-Xmx8G
-XX:MaxTenuringThreshold=14
-XX:NewSize=2184M
-XX:MaxNewSize=2184M
-XX:SurvivorRatio=1

根据该设置,我希望我的 Eden 大小和 2 个 Survivors 的大小都相同,均为 728M。通过对 VisualVM/VisualGC 的观察,这就是我们得到的结果。

这里是我的详细 gc 日志的摘录:

2014-09-16T16:42:15.357+0200: 6.796: [GC 6.796: [ParNew Desired survivor size 381681664 bytes, new threshold 14 (max 14)
- age 1: 16125960 bytes, 16125960 total
- age 2: 16259512 bytes, 32385472 total
- age 3: 2435240 bytes, 34820712 total
- age 4: 17179320 bytes, 52000032 total
- age 5: 43986952 bytes, 95986984 total
- age 6: 20858328 bytes, 116845312 total
- age 7: 31571664 bytes, 148416976 total
- age 8: 41614872 bytes, 190031848 total
- age 9: 33191568 bytes, 223223416 total
- age 10: 22887432 bytes, 246110848 total
- age 11: 168 bytes, 246111016 total
- age 12: 184 bytes, 246111200 total
: 1006811K->407353K(1490944K), 0.3248414 secs] 1006811K->407353K(7643136K), 0.3252604 secs] [Times: user=3.70 sys=0.04, real=0.33 secs]
2014-09-16T16:42:24.650+0200: 16.089: [GC 16.089: [ParNew Desired survivor size 381681664 bytes, new threshold 14 (max 14)
- age 1: 21959968 bytes, 21959968 total
- age 2: 11169584 bytes, 33129552 total
- age 3: 15663128 bytes, 48792680 total
- age 4: 2435168 bytes, 51227848 total
- age 5: 17177584 bytes, 68405432 total
- age 6: 43976040 bytes, 112381472 total
- age 7: 20246264 bytes, 132627736 total
- age 8: 31478896 bytes, 164106632 total
- age 9: 41613872 bytes, 205720504 total
- age 10: 33190832 bytes, 238911336 total
- age 11: 22889304 bytes, 261800640 total
- age 12: 168 bytes, 261800808 total
- age 13: 184 bytes, 261800992 total
: 1152825K->302652K(1490944K), 0.3356240 secs] 1152825K->302652K(7643136K), 0.3360389 secs] [Times: user=3.96 sys=0.03, real=0.34 secs]
  1. 为什么所需的幸存者大小等于“幸存者空间大小/2”?

我知道 JVM 交替使用了 2 个幸存者(每个 728Mb),但我无法理解为什么它似乎使用了 728Mb 的一半(定义内存何时被使用的所需幸存者大小)

  1. 从一个 GC 到另一个 GC,年龄 x+1 的字节应该等于或小于上一个 GC 的年龄 x 的字节。但在我的示例中,为什么第二次 GC 的年龄 11(22889304 字节)高于第一次 GC 的年龄 10(22887432 字节)?

最佳答案

目标 SurvivorRation 的默认值为 50%。查看jvm选项-XX:TargetSurvivorRatio=50

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

关于Java 垃圾收集器 : How is "Desired Survivor Size" calculated?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25887715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com