不同gc垃圾回收器组合及日志样例

不同的jvm参数所使用的老年代、年轻代组合如下图。
这里写图片描述

参数新生代老年代
-XX:+UseSerialGCSerial(DefNew)Serial Old
-XX:+UseParNewGCParNewSerial Old
-XX:+UseConcMarkSweepGCParNewCMS + Serial Old
-XX:+UseParallelGCParallel ScavengeSerial Old
-XX:+UseParallelOldGCParallel ScavengeParallel 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]
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页