CMS主要gc经常发生

时间:2016-10-11 14:28:42

标签: java garbage-collection jvm

我正在使用CMS GC,主要的gc每2分钟或更短时间发生

我试图将CMSMaxAbortablePrecleanTime的值从5增加到10再增加到20,但它没有帮助。

有人可以帮忙吗?

以下是我正在使用的配置

-heap-size=30g 
-XX:PermSize=512m 
-XX:MaxPermSize=512m 
-XX:+UseCompressedOops -Xss256k 
-XX:+UnlockDiagnosticVMOptions 
-XX:ParGCCardsPerStrideChunk=32768 
-XX:NewSize=2g 
-XX:MaxNewSize=2g 
-XX:CMSInitiatingOccupancyFraction=45 
-XX:+UseCMSInitiatingOccupancyOnly 
-XX:CMSMaxAbortablePrecleanTime=20000

以下是GC的日志

2016-10-11T08:49:01.983-0500: 407.440: [GC [1 CMS-initial-mark: 13557029K(29360128K)] 13766753K(31247616K), 0.4483970 secs] [Times: user=0.10 sys=0.31, real=0.45 secs]
2016-10-11T08:49:02.431-0500: 407.889: [CMS-concurrent-mark-start]
2016-10-11T08:49:07.764-0500: 413.222: [GC2016-10-11T08:49:07.765-0500: 413.222: [ParNew: 1887488K->209664K(1887488K), 4.2307640 secs] 15444517K->14525267K(31247616K), 4.2309270 secs] [Times: user=4.32 sys=3.49, real=4.23 secs]
2016-10-11T08:49:22.023-0500: 427.480: [GC2016-10-11T08:49:22.023-0500: 427.480: [ParNew: 1887488K->209664K(1887488K), 1.9675120 secs] 16203091K->14978753K(31247616K), 1.9676860 secs] [Times: user=3.20 sys=1.50, real=1.96 secs]
2016-10-11T08:49:28.899-0500: 434.356: [CMS-concurrent-mark: 20.218/26.467 secs] [Times: user=58.98 sys=12.86, real=26.46 secs]
2016-10-11T08:49:28.899-0500: 434.356: [CMS-concurrent-preclean-start]
2016-10-11T08:49:28.997-0500: 434.454: [CMS-concurrent-preclean: 0.096/0.098 secs] [Times: user=0.28 sys=0.01, real=0.10 secs]
2016-10-11T08:49:28.997-0500: 434.454: [CMS-concurrent-abortable-preclean-start]
2016-10-11T08:49:34.215-0500: 439.672: [GC2016-10-11T08:49:34.215-0500: 439.672: [ParNew: 1887488K->209664K(1887488K), 1.9914300 secs] 16656577K->15383793K(31247616K), 1.9915960 secs] [Times: user=3.22 sys=1.24, real=1.99 secs]
2016-10-11T08:49:40.097-0500: 445.554: [CMS-concurrent-abortable-preclean: 9.002/11.100 secs] [Times: user=29.07 sys=3.17, real=11.10 secs]
2016-10-11T08:49:40.098-0500: 445.555: [GC[YG occupancy: 1113559 K (1887488 K)]2016-10-11T08:49:40.098-0500: 445.555: [Rescan (parallel) , 0.6648450 secs]2016-10-11T08:49:40.763-0500: 446.220: [weak refs processing, 0.0005380 secs]2016-10-11T08:49:40.764-0500: 446.221: [class unloading, 0.0115730 secs]2016-10-11T08:49:40.775-0500: 446.233: [scrub symbol table, 0.0120750 secs]2016-10-11T08:49:40.788-0500: 446.245: [scrub string table, 0.0011940 secs] [1 CMS-remark: 15174129K(29360128K)] 16287688K(31247616K), 0.6943980 secs] [Times: user=2.65 sys=0.00, real=0.69 secs]
2016-10-11T08:49:40.793-0500: 446.250: [CMS-concurrent-sweep-start]
2016-10-11T08:49:43.096-0500: 448.553: [GC2016-10-11T08:49:43.096-0500: 448.553: [ParNew: 1887318K->209664K(1887488K), 0.4514140 secs] 16282520K->14815052K(31247616K), 0.4515870 secs] [Times: user=1.67 sys=0.00, real=0.45 secs]
2016-10-11T08:49:46.798-0500: 452.255: [CMS-concurrent-sweep: 5.552/6.005 secs] [Times: user=19.43 sys=1.14, real=6.00 secs]
2016-10-11T08:49:46.798-0500: 452.255: [CMS-concurrent-reset-start]
2016-10-11T08:49:47.236-0500: 452.693: [CMS-concurrent-reset: 0.438/0.438 secs] [Times: user=0.79 sys=0.50, real=0.44 secs]
2016-10-11T08:49:49.244-0500: 454.701: [GC [1 CMS-initial-mark: 13969830K(29360128K)] 15630493K(31247616K), 2.1488470 secs] [Times: user=2.15 sys=0.00, real=2.15 secs]
2016-10-11T08:49:51.394-0500: 456.851: [CMS-concurrent-mark-start]

1 个答案:

答案 0 :(得分:0)

根据选项 CMSInitiatingOccupancyFraction ,您的标记阶段将从堆的45%开始,在您的情况下将 14495514K

根据您的GC日志:

  

2016-10-11T08:49:07.764-0500:413.222:[GC2016-10-11T08:49:07.765-0500:413.222:[ParNew:1887488K-> 209664K(1887488K),4.2307640 secs] 15444517K-> ; 14525267K (31247616K),4.2309270秒] [时间:用户= 4.32 sys = 3.49,真实= 4.23秒]

完整GC后的实时数据集为14525267K,高于上述阈值,因此您将面临几乎恒定的GC。

您应该增加CMSInitiatingOccupancyFraction,以便它可以容纳您的实时数据集。它应该高于你的实时数据集+年轻的堆大小,在你的情况下大约是16,5G - 我说设置 CMSInitiatingOccupancyFraction = 55应该会改善你的情况。