为什么From/To space的大小几乎变成 0 了呢?
yuyijq
2014-01-20
Hi,请教一个问题:
一台机器 jstat -heap的结果如下: shenjia.yang 17:08 Heap Configuration: MinHeapFreeRatio = 40 MaxHeapFreeRatio = 70 MaxHeapSize = 2147483648 (2048.0MB) NewSize = 268435456 (256.0MB) MaxNewSize = 17592186044415 MB OldSize = 5439488 (5.1875MB) NewRatio = 2 SurvivorRatio = 8 PermSize = 268435456 (256.0MB) MaxPermSize = 268435456 (256.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 714735616 (681.625MB) used = 113395384 (108.14226531982422MB) free = 601340232 (573.4827346801758MB) 15.865360765791193% used From Space: capacity = 524288 (0.5MB) used = 131072 (0.125MB) free = 393216 (0.375MB) 25.0% used To Space: capacity = 458752 (0.4375MB) used = 0 (0.0MB) free = 458752 (0.4375MB) 0.0% used PS Old Generation capacity = 1431699456 (1365.375MB) used = 330222976 (314.9251708984375MB) free = 1101476480 (1050.4498291015625MB) 23.065104524283623% used PS Perm Generation capacity = 268435456 (256.0MB) used = 60564936 (57.75922393798828MB) free = 207870520 (198.24077606201172MB) 22.562196850776672% used 启动参数是: -Xms2048m -Xmx2048m -XX:NewSize=256m -XX:PermSize=256m -server -XX:+DisableExplicitGC -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails SurvivorRatio是 8 ,这个时候Eden 也 600多M,为啥From/To 几乎是 0 呢? Jdk version java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) |
|
RednaxelaFX
2014-01-21
因为ParallelScavenge GC会动态调整各个区的大小。这个行为叫做adaptive size policy。要禁用的话请用 -XX:-UseAdaptiveSizePolicy 。可以通过 -XX:+PrintAdaptiveSizePolicy 来观察它对各个区的大小的调整。
如果survivor space都几乎变成0了,多半意味着tenuring threshold已经降到1了,也就是说所有eden里活的对象在经历第一次minor GC的时候就会被晋升到old generation。那样的话survivor space就完全没用了,所以会被设置到几乎0。(无法真的完全设置到0大小是实现上的细节…有分区之间有对齐需求) 为啥tenuring threshold会下降,最终降到1?有两种可能: 1. minor GC耗时比期望的时间长。为了降低minor GC的耗时,降低tenuring threshold来让更多对象晋升,减少留在young generation里的对象 2. survivor space有溢出 说到底还是创建对象太多太快了嗯 |