-2

为什么即使young gen、tenured gen 和perm gen 有可用空间,也会每4000 秒发生一次full 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参数:

-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] 
4

1 回答 1

1

一种可能的解释是System.gc()定期调用某些东西。它可能是您的代码,也可能是您正在使用的库代码;例如,由核心 API 调用的 System.gc()

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

于 2012-10-06T14:00:01.067 回答