CMS常見錯誤

** 碎片參數(shù) **

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

** Concurrent mode failure **

  1. 設(shè)置-XX:CMSInitiatingOccupancyFraction
  2. 增大old區(qū)的大小
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.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市莲趣,隨后出現(xiàn)的幾起案子整陌,更是在濱河造成了極大的恐慌衙荐,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,590評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蛉腌,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)顽聂,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,157評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來盯仪,“玉大人紊搪,你說我怎么就攤上這事∪埃” “怎么了耀石?”我有些...
    開封第一講書人閱讀 169,301評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長爸黄。 經(jīng)常有香客問我滞伟,道長,這世上最難降的妖魔是什么炕贵? 我笑而不...
    開封第一講書人閱讀 60,078評論 1 300
  • 正文 為了忘掉前任梆奈,我火速辦了婚禮,結(jié)果婚禮上称开,老公的妹妹穿的比我還像新娘亩钟。我一直安慰自己,他們只是感情好鳖轰,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,082評論 6 398
  • 文/花漫 我一把揭開白布径荔。 她就那樣靜靜地躺著,像睡著了一般脆霎。 火紅的嫁衣襯著肌膚如雪总处。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,682評論 1 312
  • 那天睛蛛,我揣著相機(jī)與錄音鹦马,去河邊找鬼。 笑死忆肾,一個胖子當(dāng)著我的面吹牛荸频,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播客冈,決...
    沈念sama閱讀 41,155評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼旭从,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起和悦,我...
    開封第一講書人閱讀 40,098評論 0 277
  • 序言:老撾萬榮一對情侶失蹤退疫,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后鸽素,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體褒繁,經(jīng)...
    沈念sama閱讀 46,638評論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,701評論 3 342
  • 正文 我和宋清朗相戀三年馍忽,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了棒坏。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,852評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡遭笋,死狀恐怖坝冕,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情瓦呼,我是刑警寧澤喂窟,帶...
    沈念sama閱讀 36,520評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站吵血,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏偷溺。R本人自食惡果不足惜蹋辅,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,181評論 3 335
  • 文/蒙蒙 一砸王、第九天 我趴在偏房一處隱蔽的房頂上張望粹舵。 院中可真熱鬧赤拒,春花似錦艺演、人聲如沸搂鲫。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,674評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽粪躬。三九已至袄友,卻和暖如春殿托,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背剧蚣。 一陣腳步聲響...
    開封第一講書人閱讀 33,788評論 1 274
  • 我被黑心中介騙來泰國打工支竹, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人鸠按。 一個月前我還...
    沈念sama閱讀 49,279評論 3 379
  • 正文 我出身青樓礼搁,卻偏偏與公主長得像,于是被迫代替她去往敵國和親目尖。 傳聞我的和親對象是個殘疾皇子馒吴,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,851評論 2 361

推薦閱讀更多精彩內(nèi)容

  • 原文閱讀 前言 這段時(shí)間懈怠了,罪過! 最近看到有同事也開始用上了微信公眾號寫博客了饮戳,挺好的~給他們點(diǎn)贊豪治,這博客我...
    碼農(nóng)戲碼閱讀 5,994評論 2 31
  • 一次CMS GC問題排查過程(理解原理+讀懂GC日志) - iamzhongyong - ITeye技術(shù)網(wǎng)站 h...
    葡萄喃喃囈語閱讀 1,982評論 0 11
  • 簡書 占小狼轉(zhuǎn)載請注明原創(chuàng)出處,謝謝 上周有幸給部門的小伙伴分享了一些JVM相關(guān)的知識莹捡,在整個做PPT的過程中鬼吵,也...
    美團(tuán)Java閱讀 8,260評論 19 76
  • 這篇文章是我之前翻閱了不少的書籍以及從網(wǎng)絡(luò)上收集的一些資料的整理,因此不免有一些不準(zhǔn)確的地方篮赢,同時(shí)不同JDK版本的...
    高廣超閱讀 15,629評論 3 83
  • 介紹JVM中7個區(qū)域齿椅,然后把每個區(qū)域可能造成內(nèi)存的溢出的情況說明 程序計(jì)數(shù)器:看做當(dāng)前線程所執(zhí)行的字節(jié)碼行號指示器...
    jemmm閱讀 2,234評論 0 9