GC日志参数详解
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
1 輸出GC簡(jiǎn)要信息
-verbose:gc 或-XX:+PrintGC
[GC (Allocation Failure) 7987K->5378K(19456K), 0.0133927 secs][GC (Allocation Failure) 13570K->11246K(19456K), 0.0220739 secs][Full GC (Ergonomics) 11246K->11188K(19456K), 0.2417921 secs][Full GC (Ergonomics) 18717K->16418K(19456K), 0.2618319 secs][Full GC (Allocation Failure) 16418K->16398K(19456K), 0.1658426 secs]?
7987K->5378K(19456K),?0.0133927?secs含義:GC前已使用容量->GC后已使用容量(總?cè)萘?#xff09;,GC耗時(shí),單位s
GC (Allocation Failure) :說明GC類型,括號(hào)中說明發(fā)生GC的原因。如這里說明發(fā)生了minor?gc,原因是內(nèi)存分配失敗。
2 輸出GC詳細(xì)信息
-XX:+PrintGCDetails
[GC (Allocation Failure) [PSYoungGen: 7970K->1017K(9216K)] 7970K->5382K(19456K), 0.0165871 secs] [Times: user=0.05 sys=0.00, real=0.02 secs] [GC (Allocation Failure) --[PSYoungGen: 9209K->9209K(9216K)] 13574K->19444K(19456K), 0.0325471 secs] [Times: user=0.08 sys=0.00, real=0.03 secs] [Full GC (Ergonomics) [PSYoungGen: 9209K->0K(9216K)] [ParOldGen: 10234K->10180K(10240K)] 19444K->10180K(19456K), [Metaspace: 3150K->3150K(1056768K)], 0.2389364 secs] [Times: user=0.36 sys=0.00, real=0.24 secs]?[PSYoungGen:?7970K->1017K(9216K)] 含義:新生代:GC前已使用容量->GC后已使用容量(新生代總?cè)萘?#xff09;
7970K->5382K(19456K)含義:整個(gè)java堆:GC前已使用容量->GC后已使用總?cè)萘?#xff08;java堆總?cè)萘?#xff09;
?0.0165871?secs 含義:GC耗時(shí),單位s
HeapPSYoungGen total 9216K, used 8192K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)eden space 8192K, 100% used [0x00000000ff600000,0x00000000ffe00000,0x00000000ffe00000)from space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)to space 1024K, 48% used [0x00000000fff00000,0x00000000fff7be10,0x0000000100000000)ParOldGen total 10240K, used 7990K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)object space 10240K, 78% used [0x00000000fec00000,0x00000000ff3cd898,0x00000000ff600000)Metaspace used 3182K, capacity 4600K, committed 4864K, reserved 1056768Kclass space used 357K, capacity 424K, committed 512K, reserved 1048576KPSYoungGen??????total?9216K,?used?8192K?[0x00000000ff600000,?0x0000000100000000,?0x0000000100000000)含義:
新生代總大小9216K,已使用8192K,內(nèi)存申請(qǐng)起始地址,已申請(qǐng)到的終點(diǎn)位置,最多能申請(qǐng)到的位置
3 GC前后堆的詳細(xì)信息
-XX:+PrintHeapAtGC
{Heap before GC invocations=1 (full 0):PSYoungGen total 9216K, used 7969K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)eden space 8192K, 97% used [0x00000000ff600000,0x00000000ffdc86a8,0x00000000ffe00000)from space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)to space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)ParOldGen total 10240K, used 0K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)object space 10240K, 0% used [0x00000000fec00000,0x00000000fec00000,0x00000000ff600000)Metaspace used 3150K, capacity 4600K, committed 4864K, reserved 1056768Kclass space used 353K, capacity 424K, committed 512K, reserved 1048576K[GC (Allocation Failure) [PSYoungGen: 7969K->1001K(9216K)] 7969K->5366K(19456K), 0.0150862 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] Heap after GC invocations=1 (full 0):PSYoungGen total 9216K, used 1001K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)eden space 8192K, 0% used [0x00000000ff600000,0x00000000ff600000,0x00000000ffe00000)from space 1024K, 97% used [0x00000000ffe00000,0x00000000ffefa798,0x00000000fff00000)to space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)ParOldGen total 10240K, used 4364K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)object space 10240K, 42% used [0x00000000fec00000,0x00000000ff0432e0,0x00000000ff600000)Metaspace used 3150K, capacity 4600K, committed 4864K, reserved 1056768Kclass space used 353K, capacity 424K, committed 512K, reserved 1048576K}invocations=1:發(fā)生GC的總次數(shù)(Major GC, Full GC)
full?0:發(fā)生Full GC的總次數(shù)
4 OOM dump文件轉(zhuǎn)儲(chǔ)
-XX:+HeapDumpOnOutOfMemoryError :發(fā)生OutOfMemoryError時(shí),轉(zhuǎn)儲(chǔ)堆快照
-XX:HeapDumpPath=E:\java\dump :指定dump文件路徑,不指定則默認(rèn)放到項(xiàng)目路徑下
可使用Memory Analyzer分析dump文件,
Eclipse安裝地址:http://download.eclipse.org/mat/1.6.1/update-site/
下載地址:http://www.eclipse.org/mat/downloads.php
5 其他GC參數(shù)
-XX:+PrintGCTimeStamps:GC發(fā)生的時(shí)間,自JVM啟動(dòng)以后以秒計(jì)量
-XX:+PrintGCApplicationStoppedTime:輸出GC造成應(yīng)用暫停的時(shí)間,如:
Total?time?for?which?application?threads?were?stopped:?0.3797230?seconds,?Stopping?threads?took:?0.0000215?seconds
-XX:+PrintGCDateStamps:GC發(fā)生的時(shí)間,格式如:
2017-03-21T20:50:40.130+0800
-Xloggc:/logs/gc.log ?輸出GC日志到文件
歡迎指出本文有誤的地方,轉(zhuǎn)載請(qǐng)注明原文出處https://my.oschina.net/7001/blog/870988
轉(zhuǎn)載于:https://my.oschina.net/7001/blog/870988
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
- 上一篇: 你应该知道的Excel 2007小技巧
- 下一篇: BAT 面试Java技术问题总结