常见的GC日志笔记
日志配置
在VM argument選項中可配置如下:
-Xms256m --jvm堆的最小值
-Xmx256m --jvm堆的最大值
-XX:+PrintGCTimeStamps -- 打印出GC的時間信息
-XX:+PrintGCDetails --打印出GC的詳細信息
-verbose:gc --開啟gc日志
-Xloggc:d:/gc.log -- gc日志的存放位置
-Xmn10M -- 新生代內存區域的大小
-XX:SurvivorRatio=8 --新生代內存區域中Eden和Survivor的比例
PS日志
[GC(Allocation Failure)
>[GC表示YGC,否則是FGC(GC原因
[DefNew:5698->129k(7268k),0.03735498 secs]
>[年代:回收前年輕代空間->回收后年輕代空間(年輕代總大?。?,耗時]
5698k->3465k(1984k),0.09856210 secs]**
>回收前堆占用空間->回收后堆占用空間(堆總空間),耗時]
[Times:user=0.00 sys=0.09,rel=0.09 secs]
>[Linux times:用戶耗時,系統耗時,真正耗時]
eden space 5632K, 94% used [0x00000000ff980000,0x00000000ffeb3e28,0x00000000fff00000)
> 后面的內存地址指的是,起始地址,使用空間結束地址,整體空間結束地址
Metaspace used 3529k,capacity 5569k,committed 5864k,reserved 116795l
> 已經使用,總容量,虛擬內存占用,虛擬內存保留
CMS日志
使用命令 -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC 可以表示打印GC日志詳情,使用CMS垃圾回收器
[GC (Allocation Failure) [ParNew: 6144K->640K(6144K), 0.0265885 secs] 6585K->2770K(19840K), 0.0268035 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]
>ParNew:年輕代回收器
[GC (CMS Initial Mark) [1 CMS-initial-mark: 8511K(13696K)] 9866K(19840K), 0.0040321 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
>CMS-initial-mark表示mixed模式開啟,混合回收。8511 (13696) : 老年代使用(最大),9866 (19840) : 整個堆使用(最大)
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.018/0.018 secs] [Times: user=0.01 sys=0.00, real=0.02 secs]
>這里的時間意義不大,因為是并發執行
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
>標記Card為Dirty,也稱為Card Marking
[GC (CMS Final Remark) [YG occupancy: 1597 K (6144 K)][Rescan (parallel) , 0.0008396 secs][weak refs processing, 0.0000138 secs][class unloading, 0.0005404 secs][scrub symbol table, 0.0006169 secs][scrub string table, 0.0004903 secs][1 CMS-remark: 8511K(13696K)] 10108K(19840K), 0.0039567 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
>STW階段,YG occupancy:年輕代占用及容量
>[Rescan (parallel):STW下的存活對象標記
>weak refs processing: 弱引用處理
>class unloading: 卸載用不到的class
>scrub symbol(string) table:
>cleaning up symbol and string tables which hold class-level metadata and
>internalized string respectively
>CMS-remark: 8511K(13696K): 階段過后的老年代占用及容量
>10108K(19840K): 階段過后的堆占用及容量
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.005/0.005 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
>標記已經完成,進行并發清理
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
>重置內部結構,為下次GC做準備
G1日志
[GC pause (G1 Evacuation Pause) (young) (initial-mark), 0.0015790 secs]
>young -> 年輕代 Evacuation-> 復制存活對象
>initial-mark 混合回收的階段,這里是YGC混合老年代回收
[Parallel Time: 1.5 ms, GC Workers: 1]
>一個GC線程
[GC Worker Start (ms): 92635.7]
[Ext Root Scanning (ms): 1.1]
[Update RS (ms): 0.0]
[Processed Buffers: 1]
[Scan RS (ms): 0.0]
[Code Root Scanning (ms): 0.0]
[Object Copy (ms): 0.1]
[Termination (ms): 0.0]
[Termination Attempts: 1]
[GC Worker Other (ms): 0.0]
[GC Worker Total (ms): 1.2]
[GC Worker End (ms): 92636.9]
[Code Root Fixup: 0.0 ms]
[Code Root Purge: 0.0 ms]
[Clear CT: 0.0 ms]
[Other: 0.1 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 0.0 ms]
[Ref Enq: 0.0 ms]
[Redirty Cards: 0.0 ms]
[Humongous Register: 0.0 ms]
[Humongous Reclaim: 0.0 ms]
[Free CSet: 0.0 ms]
[Eden: 0.0B(1024.0K)->0.0B(1024.0K) Survivors: 0.0B->0.0B Heap: 18.8M(20.0M)->18.8M(20.0M)]
[Times: user=0.00 sys=0.00, real=0.00 secs]
>以下是混合回收其他階段
[GC concurrent-root-region-scan-start]
[GC concurrent-root-region-scan-end, 0.0000078 secs]
[GC concurrent-mark-start]
>無法evacuation,進行FGC
[Full GC (Allocation Failure) 18M->18M(20M), 0.0719656 secs]
[Eden: 0.0B(1024.0K)->0.0B(1024.0K) Survivors: 0.0B->0.0B Heap: 18.8M(20.0M)->18.8M(20.0M)], [Metaspace: 38
76K->3876K(1056768K)] [Times: user=0.07 sys=0.00, real=0.07 secs]
總結
- 上一篇: Oracle中Clob类型处理解析
- 下一篇: 一、STM32简介、选型及其目标