1. 程式人生 > >不同gc垃圾回收器組合及日誌樣例

不同gc垃圾回收器組合及日誌樣例

不同的jvm引數所使用的老年代、年輕代組合如下圖。
這裡寫圖片描述

引數 新生代 老年代
-XX:+UseSerialGC Serial(DefNew) Serial Old
-XX:+UseParNewGC ParNew Serial Old
-XX:+UseConcMarkSweepGC ParNew CMS + Serial Old
-XX:+UseParallelGC Parallel Scavenge Serial Old
-XX:+UseParallelOldGC Parallel Scavenge Parallel Old

舉幾個例子。

1 -XX:+UseSerialGC

啟用序列GC,即採用Serial+Serial Old模式,client模式預設值

2018-04-27T13:12:49.630+0800: 3.223: [GC 3.223: [DefNew: 3276K->709K(92160K), 0.0098035 secs]3.233: [Tenured: 361200K->709K(409600K), 0.0114333 secs] 364476K->709K(501760K), [Perm : 3102K->3102K(21248K)], 0.0213359 secs] [Times
: user=0.03 sys=0.00, real=0.02 secs]

2 -XX:+UseParNewGC

使用ParNew+Serial Old收集器組合,不推薦

2018-04-27T13:19:26.996+0800: 3.282: [GC 3.282: [ParNew: 3276K->743K(92160K), 0.0054274 secs]3.287: [Tenured: 361200K->709K(409600K), 0.0113318 secs] 364476K->709K(501760K), [Perm : 3102K->3102K(21248K)], 0.0168826 secs] [Times
: user=0.08 sys=0.00, real=0.02 secs]

3 -XX:+UseConcMarkSweepGC

使用ParNew+CMS+Serial Old組合併發收集,優先使用ParNew+CMS,當用戶執行緒記憶體不足時,採用備用方案Serial Old收集。

2018-04-27T13:23:35.961+0800: 1.102: [GC 1.102: [ParNew: 2780K->744K(78144K), 0.0033055 secs]1.106: [CMS: 120400K->713K(173632K), 0.0143163 secs] 123180K->713K(251776K), [CMS Perm : 3103K->3101K(21248K)], 0.0177658 secs] [Times: user=0.01 sys=0.00, real=0.02 secs] 
2018-04-27T13:23:35.994+0800: 1.135: [GC [1 CMS-initial-mark: 121113K(173632K)] 121113K(251840K), 0.0001263 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:35.994+0800: 1.135: [CMS-concurrent-mark-start]
2018-04-27T13:23:35.998+0800: 1.139: [CMS-concurrent-mark: 0.003/0.004 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:35.998+0800: 1.139: [CMS-concurrent-preclean-start]
2018-04-27T13:23:35.999+0800: 1.140: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:35.999+0800: 1.140: [CMS-concurrent-abortable-preclean-start]
2018-04-27T13:23:36.995+0800: 2.136: [GC 2.136: [ParNew: 2783K->190K(78208K), 0.0017561 secs]2.137: [CMS2018-04-27T13:23:36.996+0800: 2.137: [CMS-concurrent-abortable-preclean: 0.009/0.997 secs] [Times: user=0.02 sys=0.00, real=1.00 secs] 
 (concurrent mode failure): 121113K->628K(173632K), 0.0136789 secs] 123896K->628K(251840K), [CMS Perm : 3104K->3104K(21248K)], 0.0155741 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 
dddd
2018-04-27T13:23:38.035+0800: 3.176: [GC 3.176: [ParNew: 0K->0K(78208K), 0.0015648 secs]3.178: [CMS: 121028K->628K(173632K), 0.0126110 secs] 121028K->628K(251840K), [CMS Perm : 3104K->3104K(21248K)], 0.0143089 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 
2018-04-27T13:23:38.072+0800: 3.213: [GC [1 CMS-initial-mark: 121028K(173632K)] 121028K(251840K), 0.0001420 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:38.072+0800: 3.213: [CMS-concurrent-mark-start]
2018-04-27T13:23:38.077+0800: 3.218: [CMS-concurrent-mark: 0.004/0.004 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:38.077+0800: 3.218: [CMS-concurrent-preclean-start]
2018-04-27T13:23:38.078+0800: 3.219: [CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:38.078+0800: 3.219: [GC[YG occupancy: 0 K (78208 K)]3.219: [Rescan (parallel) , 0.0009488 secs]3.220: [weak refs processing, 0.0000088 secs]3.220: [scrub string table, 0.0000773 secs] [1 CMS-remark: 121028K(173632K)] 121028K(251840K), 0.0011589 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:38.079+0800: 3.220: [CMS-concurrent-sweep-start]
2018-04-27T13:23:38.080+0800: 3.221: [CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2018-04-27T13:23:38.080+0800: 3.221: [CMS-concurrent-reset-start]
2018-04-27T13:23:38.081+0800: 3.222: [CMS-concurrent-reset: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 

4 -XX:+UseParallelGC

開啟此引數使用parallel scavenge & parallel old蒐集器(server模式預設值)。
以下為jdk5版本下

[GC [PSYoungGen: 883K->498K(3584K)] 241683K->241322K(276672K), 0.0024777 secs]
[GC [PSYoungGen: 498K->498K(3584K)] 241322K->241338K(276672K), 0.0027416 secs]
[Full GC [PSYoungGen: 498K->0K(3584K)] [PSOldGen: 240840K->371K(17344K)] 241338K->371K(20928K) [PSPermGen: 3284K->3284K(21248K)], 0.0347810 secs]