CMSInitiatingOccupancyFraction值与Xmn的关系公式

promontion faild产生的原因是EDEN空间不足的情况下将EDEN与From survivor中的存活对象存入To survivor区时,To survivor区的空间不足,再次晋升到old gen区,而old gen区内存也不够的情况下产生了promontion faild从而导致full gc.那可以推断出:eden+from survivor < old gen区剩余内存时,不会出现promontion faild的情况,即:
(Xmx-Xmn)*(1-CMSInitiatingOccupancyFraction/100)>=(Xmn-Xmn/(SurvivorRatior+2))  进而推断出:

CMSInitiatingOccupancyFraction <=((Xmx-Xmn)-(Xmn-Xmn/(SurvivorRatior+2)))/(Xmx-Xmn)*100

例如:
当xmx=2048 xmn=256 SurvivorRatior=8(默认值)时  CMSInitiatingOccupancyFraction<=((2048-256)-(2048-256/(8+2)))/(2048-256)*100=87.14

当xmx=128 xmn=36 SurvivorRatior=1时 CMSInitiatingOccupancyFraction<=((128.0-36)-(36-36/(1+2)))/(128-36)*100 =73.913

当xmx=128 xmn=24 SurvivorRatior=1时 CMSInitiatingOccupancyFraction<=((128.0-24)-(24-24/(1+2)))/(128-24)*100=84.615…

当xmx=3000 xmn=600 SurvivorRatior=1时  CMSInitiatingOccupancyFraction<=((3000.0-600)-(600-600/(1+2)))/(3000-600)*100=83.33

CMSInitiatingOccupancyFraction低于70% 需要调整xmn或SurvivorRatior值。

通过CMSInitiatingOccupancyFraction计算公式,计算得出value为73是,可以避免promotion faild问题,同时满足堆内存监控报警值在80%:内存大小128M*80%=102.4M 102.4M-36M=66.4M(老生代达到此值报警) 老生代达到67.15M(92M*0.73)将发生Full GC,所以在老生代大小达到66.4M时也就是WARN报警时将很有可能出现Full GC。

你可能感兴趣的:(action)