虽然Old gen不是半满的,但CMS标记的数量很多

时间:2015-08-31 00:56:35

标签: garbage-collection concurrent-mark-sweep

我正在努力了解大量CMS标记和备注(其他阶段)平均大约700ms的原因,即使旧版本甚至没有半满。以下是GCViewer的GC配置和统计数据。

-Xms3g 
-Xmx3g 
-XX:NewSize=1800m 
-XX:MaxNewSize=1800m
-XX:MaxPermSize=256m
-XX:SurvivorRatio=8
-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled

使用GC查看器汇总:http://i.imgur.com/0IIbNUr.png

GC日志

152433.761: [GC [1 CMS-initial-mark: 284761K(1302528K)] 692884K(2961408K), 0.3367298 secs] [Times: user=0.33 sys=0.00, real=0.34 secs] 
152434.098: [CMS-concurrent-mark-start]
152434.417: [CMS-concurrent-mark: 0.318/0.318 secs] [Times: user=1.38 sys=0.02, real=0.32 secs] 
152434.417: [CMS-concurrent-preclean-start]
152434.426: [CMS-concurrent-preclean: 0.008/0.009 secs] [Times: user=0.02 sys=0.00, real=0.01 secs] 
152434.426: [CMS-concurrent-abortable-preclean-start]
 CMS: abort preclean due to time 152439.545: [CMS-concurrent-abortable-preclean: 4.157/5.119 secs] [Times: user=5.82 sys=0.20, real=5.12 secs] 
152439.549: [GC[YG occupancy: 996751 K (1658880 K)]152439.550: [Rescan (parallel) , 0.5383841 secs]152440.088: [weak refs processing, 0.0070783 secs]152440.095: [class unloading, 0.0777632 secs]152440.173: [scrub symbol & string tables, 0.0416825 secs] [1 CMS-remark: 284761K(1302528K)] 1281512K(2961408K), 0.6771800 secs] [Times: user=3.35 sys=0.02, real=0.68 secs] 
152440.227: [CMS-concurrent-sweep-start]
152440.613: [CMS-concurrent-sweep: 0.382/0.386 secs] [Times: user=0.39 sys=0.01, real=0.39 secs] 
152440.613: [CMS-concurrent-reset-start]
152440.617: [CMS-concurrent-reset: 0.004/0.004 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 
152441.719: [GC [1 CMS-initial-mark: 284757K(1302528K)] 1320877K(2961408K), 0.7720557 secs] [Times: user=0.78 sys=0.01, real=0.77 secs] 
152442.492: [CMS-concurrent-mark-start]

1 个答案:

答案 0 :(得分:0)

CMS的评论必须扫描年轻一代,因为你的年轻一代是如此之大,这需要一些时间。根据java版本(您未指定!),您可能必须启用并行重新标记(CMSParallelRemarkEnabled)。

启用CMSScavengeBeforeRemark也可能会减少备注期间需要扫描的内存量。

简单地缩小新一代并获得更多促销活动,然后通过并发的旧版GC清理出来也可能会有效。

我认为增量模式不会在这里修复任何内容,它只是彻底改变了CMS的行为,它掩盖了你的原始问题。