加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

JVM产生CMS GC的 5 种环境,你知道的必定不全!

发布时间:2019-06-12 22:35:57 所属栏目:站长百科 来源:涤生YQ
导读:常常有同窗会问,为啥我的应用 Old Gen 的行使占比没到达 CMSInitiatingOccupancyFraction 参数设置的阈值,就触发了 CMS GC,暗示很莫名奇奥,不知道题目出在哪? 着实 CMS GC 的触发前提很是多,不可是 CMSInitiatingOccupancyFraction 阈值触发这么简朴

判定逻辑是,假如猜测 CMS GC 完成所必要的时刻大于估量的晚年月将要填满的时刻,则举办 GC。 这些判定是必要基于汗青的 CMS GC 统计指标,然而,第一次 CMS GC 时,统计数据还没有形成,是无效的,这时会跟据 Old Gen 的行使占比来判定是否要举办 GC。

  1. if (!UseCMSInitiatingOccupancyOnly) { 
  2. if (stats().valid()) { 
  3. if (stats().time_until_cms_start() == 0.0) { 
  4. return true; 
  5. } else { 
  6. // We want to conservatively collect somewhat early in order 
  7. // to try and "bootstrap" our CMS/promotion statistics; 
  8. // this branch will not fire after the first successful CMS 
  9. // collection because the stats should then be valid. 
  10. if (_cmsGen->occupancy() >= _bootstrap_occupancy) { 
  11. if (Verbose && PrintGCDetails) { 
  12. gclog_or_tty->print_cr( 
  13. " CMSCollector: collect for bootstrapping statistics:" 
  14. " occupancy = %f, boot occupancy = %f", _cmsGen->occupancy(), 
  15. _bootstrap_occupancy); 
  16. return true; 

那占几多比率,开始接纳呢?(也就是 bootstrapoccupancy 的值是几多呢?) 谜底是 50%。或者你已经碰着过相同案例,在没有设置 UseCMSInitiatingOccupancyOnly 时,发明晚年月占比到 50% 就举办了一次 CMS GC,其时的你或者还一头雾水呢。

  1. _bootstrap_occupancy = ((double)CMSBootstrapOccupancy)/(double)100; 
  2. //参数默认值 
  3. product(uintx, CMSBootstrapOccupancy, 50, 
  4. "Percentage CMS generation occupancy at which to initiate CMS collection for bootstrapping collection stats") 

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读