0

我试图了解大量 CMS 标记和评论(其他阶段也是如此)平均大约 700 毫秒的原因,即使老一代甚至没有半满。以下是来自 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]
4

1 回答 1

0

CMS remark 必须扫描年轻代,因为你的年轻代太大了,这需要一些时间。根据 Java 版本(您没有指定!),您可能必须启用并行注释 ( CMSParallelRemarkEnabled)。

启用CMSScavengeBeforeRemark还可以减少备注期间需要扫描的内存量。

并且简单地缩小新一代并接受更多的提升,然后被并发的老一代 GC 清理掉也可能会起作用。

我不认为增量模式在这里解决任何问题,它只是极大地改变了 CMS 的行为,它掩盖了你原来的问题。

于 2015-09-03T06:31:26.393 回答