我测试了一些jvm参数来看GC日志,但是发现一些细节跟我预期的并不一样, 难道我理解有问题?
如上面的GC日志
... eden space 8192K, 77% used ...
... from space 1024K, 96% used ...
... to space 1024K, 0% used ...
Young space -Xmn is a sum of eden, S0, S1 (from and to are same as S0, S1, though S0 have from role for half of collections and to role for others, same for S1).
eden + from + to = 10MiB as expected.
Though, due to logic of young collection, to space should have zero utilization at all times, so effective capacity of young space is eden + from thus 9 MiB.
In general, though, some GC variant can dynamically adjust young space size (only reduce it compared to -Xmn) so effective young space at runtime could be smaller than configured.
-Xmn 年轻代的大小是由eden,S0(from), S1(to) 三部分组成, eden + from + to = 10M 是符合你设置的JVM参数的(-Xmn10M) -Xmn控制的是新生代的总容量,由于垃圾回收算法的原因,需要预留一半的survivor区容量帮助GC,所以同一时间新生代的可用空间等于eden区+50%Survivor区,但是如果使用G1垃圾回收算法的话就不是这样了,G1因为回收策略的调整,可以在同一时间真正使用100%的新生代容量
来源:stackoverflow
赞0
踩0