即使堆上的可用空间,也会发生完整的GC

时间:2012-10-06 13:34:07

标签: java garbage-collection

为什么每4000秒就会发生一次完整的gc,即使年轻的天才,天赋和热情的人都有自由空间。

GC参数:

-XX:CMSInitiatingOccupancyFraction=50  
-XX:+UseCMSInitiatingOccupancyOnly  
-XX:+UseConcMarkSweepGC  
-XX:+UseParNewGC  
-Xloggc:GC.log  
-XX:+PrintGCDetails  
-XX:+PrintTenuringDistribution  
-XX:MaxTenuringThreshold=8  
-XX:PermSize=128M  
-XX:MaxPermSize=128M  
-XX:+CMSPermGenSweepingEnabled  

jvm args:

-Xms25G -Xmx25G

gc日志是:

22463.534: [GC 22463.534: [ParNew
Desired survivor size 8716288 bytes, new threshold 3 (max 8)
- age   1:    3725848 bytes,    3725848 total
- age   2:    3199384 bytes,    6925232 total
- age   3:    2962800 bytes,    9888032 total
: 150702K->15367K(153344K), 0.0343470 secs] 5647083K->5515157K(26197376K), 0.0344540 secs] [Times: user=0.21 sys=0.00, real=0.04 secs]
22476.236: [GC 22476.236: [ParNew
Desired survivor size 8716288 bytes, new threshold 3 (max 8)
- age   1:    4130920 bytes,    4130920 total
- age   2:    3110336 bytes,    7241256 total
- age   3:    3125208 bytes,   10366464 total
: 151687K->16210K(153344K), 0.0357830 secs] 5651477K->5519299K(26197376K), 0.0358820 secs] [Times: user=0.22 sys=0.00, real=0.04 secs]

**22478.730: [Full GC (System) 22478.730: [CMS: 5503089K->4624468K(26044032K), 33.8259070 secs] 5560326K->4624468K(26197376K), [CMS Perm : 12045K->11957K(131072K)], 33.8260340 secs] [Times: user=33.38 sys=0.06, real=33.83 secs]**

22513.164: [GC 22513.164: [ParNew
Desired survivor size 8716288 bytes, new threshold 8 (max 8)
- age   1:    4477888 bytes,    4477888 total
: 136320K->9674K(153344K), 0.0734160 secs] 4760788K->4634143K(26197376K), 0.0735590 secs] [Times: user=0.55 sys=0.00, real=0.08 secs] 
22522.765: [GC 22522.766: [ParNew
Desired survivor size 8716288 bytes, new threshold 8 (max 8)
- age   1:    3725528 bytes,    3725528 total
- age   2:    4220800 bytes,    7946328 total
: 145994K->8939K(153344K), 0.0226740 secs] 4770463K->4633407K(26197376K), 0.0228130 secs] [Times: user=0.15 sys=0.00, real=0.03 secs] 

1 个答案:

答案 0 :(得分:1)

一种可能的解释是,某些内容会定期调用System.gc()。它可能是您的代码,也可能是您正在使用的库代码;例如System.gc() calls by core APIs

您可以通过设置java选项来测试此理论,该选项告诉JVM忽略System.gc()次调用,并查看完整的GC是否停止发生。 (我提到的选项是-XX:+DisableExplicitGC ...谢谢弗兰克。)