美文网首页
CMS常见错误

CMS常见错误

作者: canezk | 来源:发表于2016-10-14 19:14 被阅读334次

** 碎片参数 **

-XX:OldPLABSize=16
-XX:-ResizeOldPLAB
-XX:+PrintGCDetails
-XX:+PrintPromotionFailure
-XX:PrintFLSStatistics=1

** Concurrent mode failure **

  1. 设置-XX:CMSInitiatingOccupancyFraction
  2. 增大old区的大小
At beginning  of each young GC, collector should ensure that there is enough free
 memory in old space to promote aged objects from young space. Modern CMS 
collector estimates size of objects to be promoted using statistics from previous
 collections. If old space does not have enough free bytes to hold estimated 
promotion amount, **concurrent mode failure** will be raise. Concurrent mode
 failure doesn't necessary lead to Full GC, in certain cases JVM will just wait for
 concurrent collection cycle to finish, but application will remain in STW pause 
until young collection will be finished.


Most frequent reason for concurrent mode failure is late initiation of CMS cycle. 
JVM tries to estimate amount of garbage in heap and duration of CMS cycle and
 start it as late as possible to avoid wasting of CPU. Unfortunately this estimation
 may be too optimistic. You can advise JVM to start CMS earlier using following
 flags:

-XX:CMSInitiatingOccupancyFraction=30-XX:+UseCMSInitiatingOccupancyOnly


Setting above will force CMS cycle is more than 30% of old space is use. Second 
option disables JVM heuristics, without second parameter JVM may not obey 
CMS initiating occupancy fraction setting.


Normally for server type applications you would like CMS to be running 
continuously. If you are experiencing **concurrent mode failure**, even though 
next CMS cycle is starting right after previous, it means that CMS throughput is 
just not enough. In this case you should increase size of old generation and give 
CMS collector more head room to do its job. Alternatively you may try to dedicate 
more CPU cores for concurrent collector, but CPU is usually even more limited 
resource on modern servers than memory.


In summary, there are two reasons for **concurrent mode failure**STW pause 
mentioned above, both of them can be remedied fairly easily with JVM options.

** Promotion failure **

Promotion failure is more complicated situation. CMS collector is not compacting 
free memory in old space, instead it have to deal with fragmented free space (a 
set of free memory chunks). It is possible, that all free bytes are scattered though 
small chunks, and it is impossible to find certain amount of continuous memory to 
promote particular large object, even though total number of free bytes is large
 enough.

Heap fragmentation is well known problem, and there are few effective techniques 
reducing fragmentation.

CMS memory manager is using separate free lists for different size of chunks. 
Using these free lists, it can effectively fill small holes in fragmented memory 
space with objects of exact size. This technique is known to be fairly effective 
(and widely used in C/C++ memory managers). But, surprisingly, it doesn't seems
 to work well for JVM in many real live situations.

相关文章

  • CMS常见错误

    ** 碎片参数 ** ** Concurrent mode failure ** 设置-XX:CMSInitiat...

  • SiteServer CMS 常见十大误区和错误

    ** 如果您觉得文章对您有点用,麻烦在您阅读、收藏、转发的时候,顺手帮忙点个赞、留个言、加关注,这是我继续写下去的...

  • java常见垃圾收集器

    常见的有Serial GC、ParNew GC、CMS GC、Parallel GC、G1 GC Serial G...

  • 常见错误

    1、spring默认只会扫描resources下的属性文件,而对于java包下的属性文件会被忽略。如果想要编译ja...

  • 常见错误

    错误1 导致原因 解决办法 错误二: library not found for - 参考 解决方法:获取 库...

  • 常见错误

    微信自定义菜单 EasyWechat :4.0最新版本 1.微信公众号配置网页授权域名微信报无法访问xxx.com...

  • 常见错误

    Test is not an annotation type描述:在使用junit进行单元测试时,在方法前声明@T...

  • 常见错误

    1、phpmyadmin 登录失败#1045无法登录MySQL服务器解决:(两种情况) 配置文件权限错误:修改ph...

  • 常见错误

    Permission Denial: opening provider 隐藏的android:exported属性...

  • 常见错误

    Xcode 7 创建新项目用到 UIWebView 发送请求时,报下面的错: “App Transport Sec...

网友评论

      本文标题:CMS常见错误

      本文链接:https://www.haomeiwen.com/subject/dacnyttx.html