在次要GC期间,对象仍然在Eden空间中存在,并且From(S1)幸存者空间被移动到To(S2)幸存者空间,从而产生空的Eden和S1空间。
因此,在较小的GC等于S2总大小之后使YoungGen大小似乎是合乎逻辑的。但根据-XX:+ PrintTenuringDistribution JVM选项报告的信息情况并非如此,它允许在GC日志中的幸存者空间中打印对象年龄。
问。为什么GC之后的YoungGen大小与空间(S2 / To)不同,因为Young Generation中的另外两个空格中没有其他对象?
以下两个次要GC日志显示差异
2016-02-26T18:28:57.745+0200: 73803.862: [GC 73803.862: [ParNew
Desired survivor size 30507008 bytes, new threshold 2 (max 4)
- age 1: 19067112 bytes, 19067112 total
- age 2: 14083544 bytes, 33150656 total
- age 3: 5637688 bytes, **38788344** total
: 526601K->**53312**K(536768K), 0.0139084 secs] 3828787K->3368267K(6231872K), 0.0140546 secs] [Times: user=0.44 sys=0.00, real=0.01 secs]
2016-02-26T18:29:08.151+0200: 73814.268: [GC 73814.268: [ParNew
Desired survivor size 30507008 bytes, new threshold 2 (max 4)
- age 1: 16633848 bytes, 16633848 total
- age 2: 16885136 bytes, 33518984 total
: 530496K->50445K(536768K), 0.0191598 secs] 3845451K>3382531K(6231872K), 0.0193089 secs]
提前致谢
修改: 只是另一个例子来说明幸存者大小在欲望幸存者大小之下的情况,由 -XX:TargetSurvivorRatio 修正,这表明幸存者的总体大小与之后的年龄大小不同GC也是。
2016-05-26T08:00:16.348+0200: 36081.537: [GC 36081.537: [ParNew
Desired survivor size 30507008 bytes, new threshold 4 (max 4)
- age 1: 10236664 bytes, 10236664 total
- age 2: 9032760 bytes, 19269424 total
- age 3: 8856944 bytes, 28126368 total
: 527551K->46932K(536768K), 0.0101126 secs] 1644990K->1173951K(6231872K), 0.0102252 secs] [Times: user=0.44 sys=0.00, real=0.01 secs]