gcCauses整理

gc causes

  • gcCause.cpp

    switch (cause) {
    case _java_lang_system_gc: return "System.gc()";
    case _full_gc_alot: return "FullGCAlot";
    case _scavenge_alot: return "ScavengeAlot";
    case _allocation_profiler: return "Allocation Profiler";
    case _jvmti_force_gc: return "JvmtiEnv ForceGarbageCollection";
    case _gc_locker: return "GCLocker Initiated GC";
    case _heap_inspection: return "Heap Inspection Initiated GC";
    case _heap_dump: return "Heap Dump Initiated GC";
    case _wb_young_gc: return "WhiteBox Initiated Young GC";
    case _update_allocation_context_stats_inc:
    case _update_allocation_context_stats_full:
    return "Update Allocation Context Stats";
    case _no_gc: return "No GC";
    case _allocation_failure: return "Allocation Failure";
    case _tenured_generation_full: return "Tenured Generation Full";
    case _metadata_GC_threshold: return "Metadata GC Threshold";
    case _cms_generation_full: return "CMS Generation Full";
    case _cms_initial_mark: return "CMS Initial Mark";
    case _cms_final_remark: return "CMS Final Remark";
    case _cms_concurrent_mark: return "CMS Concurrent Mark";
    case _old_generation_expanded_on_last_scavenge:
    return "Old Generation Expanded On Last Scavenge";
    case _old_generation_too_full_to_scavenge:
    return "Old Generation Too Full To Scavenge";
    case _adaptive_size_policy: return "Ergonomics";
    case _g1_inc_collection_pause: return "G1 Evacuation Pause";
    case _g1_humongous_allocation: return "G1 Humongous Allocation";
    case _last_ditch_collection: return "Last ditch collection";
    case _last_gc_cause: return "ILLEGAL VALUE - last gc cause - ILLEGAL VALUE";
    default: return "unknown GCCause";}


  • common occurred and explanation
    • System.gc
      • Something called System.gc().
      • If you are seeing this once an hour it is likely related to the RMI GC interval
        • sun.rmi.dgc.client.gcInterval
        • sun.rmi.dgc.server.gcInterval
        • 兩個(gè)參數(shù)默認(rèn)都是1hour
        • 關(guān)于rmi的distributed garbage collection-gcInterval
          • RMI uses a distributed garbage collection (DGC) algorithm that depends on regular garbage collection (GC) activity to determine if remote objects are candidates for collection. It helps with automatic memory management when remote objects are stored in memory
          • To ensure that the remote objects are collected in a timely fashion, RMI takes the step of triggering a System.gc() on a regular interval. However, in most cases regular GC activity is sufficient for effective DGC.
          • Disabling Explicit Garbage Collections
            • -XX:+DisableExplicitGC(關(guān)閉它會(huì)影響堆外內(nèi)存回收)
          • Do both server and client arguments need to be added?
            • The two sun.rmi arguments reflect whether your JVM is running in server or client mode. Depending on the version of your SDK, either mode can be set as the default. It is best to set both options so the argument will be picked up by the JVM
    • Allocation_Profiler
      • Prior to java 8 you would see this if running with the -Xaprof setting. It would be triggered just before the jvm exits. The -Xaprof option was removed in java 8.
      • Aprof
        • Aprof is a Java memory allocation profiler with very low performance impact on the profiled application that can be used (and is used) on highly-loaded server-side applications in production environment. It acts as an agent which transforms class bytecode by inserting counter increments wherever memory allocation is done and tracks a precise size of allocated objects in bytes. It also keeps limited information about allocation context to aid in finding the memory allocation bottlenecks. links
      • aprof-bug
    • JvmtiEnv_ForceGarbageCollection
      • Something called the JVM tool interface function ForceGarbageCollection. Look at the -agentlib param to java to see what agents are configured.(instrument agent?)
      • ForceGarbageCollection
        • http://docs.oracle.com/javase/7/docs/platform/jvmti/jvmti.html
        • jvmtiError ForceGarbageCollection(jvmtiEnv* env)
          • Force the VM to perform a garbage collection. The garbage collection is as complete as possible. This function does not cause finalizers to be run. This function does not return until the garbage collection is finished.
          • Although garbage collection is as complete as possible there is no guarantee that all ObjectFree events will have been sent by the time that this function returns. In particular, an object may be prevented from being freed because it is awaiting finalization.
    • GCLocker_Initiated_GC
      • The GC locker prevents GC from occurring when JNI code is in a critical region. If GC is needed while a thread is in a critical region, then it will allow them to complete, i.e. call the corresponding release function. Other threads will not be permitted to enter a critical region. Once all threads are out of critical regions a GC event will be triggered.
      • jni funcations
        • GetStringCritical, ReleaseStringCritical
        • GetPrimitiveArrayCritical, ReleasePrimitiveArrayCritical
      • c/c++代碼里引用jstring, jarray,通過(guò)指針引用而不是把數(shù)據(jù)copy from java heap to native heap為了性能
      • 防止操作時(shí)jstring,jarray的指針隨gc改變,需要gclocker來(lái)pin住gc happen
    • Heap_Inspection_Initiated_GC
      • GC was initiated by an inspection operation on the heap. For example you can trigger this with jmap: jmap -histo:live <pid>
    • Heap_Dump_Initiated_GC
      • GC was initiated before dumping the heap. For example you can trigger this with jmap: jmap -dump:live,format=b,file=heap.out <pid>
        Another common example would be clicking the Heap Dump button on the Monitor tab in jvisualvm.
    • No_GC
      • Used for CMS to indicate concurrent phases.
    • Allocation_Failure
      • Usually this means that there is an allocation request that is bigger than the available space in young generation and will typically be associated with a minor GC.
      • For G1 this will likely be a major GC and it is more common to see G1_Evacuation_Pause for routine minor collections.
      • On linux the jvm will trigger a GC if the kernel indicates there isn't much memory left via mem_notify.
    • CMS_Initial_Mark
      • Initial mark phase of CMS, for more details see Phases of CMS. Unfortunately it doesn't appear to be reported via the mbeans and we just get No_GC.
    • CMS_Final_Remark
      • Remark phase of CMS, for more details see Phases of CMS. Unfortunately it doesn't appear to be reported via the mbeans and we just get No_GC.
    • CMS_Concurrent_Mark
      • Concurrent mark phase of CMS, for more details see Phases of CMS. Unfortunately it doesn't appear to be reported via the mbeans and we just get No_GC.
    • Ergonomics
      • This indicates you are using the adaptive size policy, -XX:+UseAdaptiveSizePolicy and is on by default for recent versions, with the parallel collector (-XX:+UseParallelGC). For more details see The Why of GC Ergonomics.
    • Last_ditch_collection
      • For perm gen (java 7 or earlier) and metaspace (java 8+) a last ditch collection will be triggered if an allocation fails and the memory pool cannot be expanded.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末裕循,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子疲扎,更是在濱河造成了極大的恐慌榴捡,老刑警劉巖聂儒,帶你破解...
    沈念sama閱讀 206,378評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異踪少,居然都是意外死亡哆窿,警方通過(guò)查閱死者的電腦和手機(jī)农曲,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,356評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門社搅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人乳规,你說(shuō)我怎么就攤上這事形葬。” “怎么了暮的?”我有些...
    開(kāi)封第一講書人閱讀 152,702評(píng)論 0 342
  • 文/不壞的土叔 我叫張陵笙以,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我冻辩,道長(zhǎng)猖腕,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 55,259評(píng)論 1 279
  • 正文 為了忘掉前任恨闪,我火速辦了婚禮倘感,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘咙咽。我一直安慰自己老玛,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,263評(píng)論 5 371
  • 文/花漫 我一把揭開(kāi)白布钧敞。 她就那樣靜靜地躺著蜡豹,像睡著了一般。 火紅的嫁衣襯著肌膚如雪溉苛。 梳的紋絲不亂的頭發(fā)上镜廉,一...
    開(kāi)封第一講書人閱讀 49,036評(píng)論 1 285
  • 那天,我揣著相機(jī)與錄音愚战,去河邊找鬼娇唯。 笑死威根,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的视乐。 我是一名探鬼主播洛搀,決...
    沈念sama閱讀 38,349評(píng)論 3 400
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼佑淀!你這毒婦竟也來(lái)了留美?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 36,979評(píng)論 0 259
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤伸刃,失蹤者是張志新(化名)和其女友劉穎谎砾,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體捧颅,經(jīng)...
    沈念sama閱讀 43,469評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡景图,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,938評(píng)論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了碉哑。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片挚币。...
    茶點(diǎn)故事閱讀 38,059評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖扣典,靈堂內(nèi)的尸體忽然破棺而出妆毕,到底是詐尸還是另有隱情,我是刑警寧澤贮尖,帶...
    沈念sama閱讀 33,703評(píng)論 4 323
  • 正文 年R本政府宣布笛粘,位于F島的核電站,受9級(jí)特大地震影響湿硝,放射性物質(zhì)發(fā)生泄漏薪前。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,257評(píng)論 3 307
  • 文/蒙蒙 一关斜、第九天 我趴在偏房一處隱蔽的房頂上張望示括。 院中可真熱鬧,春花似錦蚤吹、人聲如沸例诀。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 30,262評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)繁涂。三九已至,卻和暖如春二驰,著一層夾襖步出監(jiān)牢的瞬間扔罪,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 31,485評(píng)論 1 262
  • 我被黑心中介騙來(lái)泰國(guó)打工桶雀, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留矿酵,地道東北人唬复。 一個(gè)月前我還...
    沈念sama閱讀 45,501評(píng)論 2 354
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像全肮,于是被迫代替她去往敵國(guó)和親敞咧。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,792評(píng)論 2 345

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