重复java垃圾收集,即使有足够的Java内存 - 为什么

时间:2011-07-20 11:21:05

标签: java garbage-collection

我们的java进程占用了大量的CPU,并且日志显示它经常执行GC,即使已使用的内存大约为5GB(取自JMX控制台),而Min和Max内存为10GB。

我们的JVM args是:JVM_GC =“ - verbose:gc -Xnoclassgc -XX:+ PrintGCDetails -XX:+ UseParNewGC -XX:NewSize = 3GB -XX:ParallelGCThreads = 8 -XX:MaxTenuringThreshold = 15 -XX:+ UseConcMarkSweepGC “

和MinHeap = MaxHeap = 10GB

知道什么可能触发GC?为什么它经常发生并且太快? 除了通过JMX获取一些设置之外,我们无法将任何类型的分析工具连接为其生产框... 谢谢 ..... GC日志....

@ 2011-07-20 02:10:46
[Full GC(System)[CMS:3333423K-> 4019122K(7340032K),13.4979250 secs] 4876606K-> 4019122K(10171200K),[CMSPerm:21656K-> 21608K(21824K)],13.4980930sec s] [时间:用户= 12.99 sys = 0.50,实际= 13.50秒]
[GC [1 CMS-initial-mark:4019122K(7340032K)] 4041525K(10171200K),0.0009110 secs] [次:用户= 0.00 sys = 0.00,实际= 0.00秒]
@ 2011-07- 20 02:11:10
[CMS-concurrent-mark:10.322 / 10.753秒] [时间:用户= 21.55 sys = 0.22,真实= 10.75秒]
[CMS-concurrent-preclean:0.035 / 0.036 secs] [次:用户= 0.04 sys = 0.00,real = 0.04 secs]
@ 2011-07-20 02:11:15 <登记/>  CMS:因时间而中止预扫[CMS-并发 - 流产 - 预清洁:1.083 / 5.063秒] [时间:用户= 1.08 sys = 0.00,实际= 5.06秒]
[GC [YG占有率:282204 K(2831168 K)] [重新扫描(平行),0.0402030秒] [弱参考处理,0.0010550秒]
[1 CMS-remark:4019122K(7340032K)] 4301 326K(10171200K),0.0413630秒] [时间:用户= 0.07 sys = 0.01,实际= 0.04秒]
@ 2011-07-20 02:11:16
[CMS-concurrent-sweep:2.627 / 2.627 secs] [时间:用户= 2.63 sys = 0.00,实际= 2.63秒]
[CMS-concurrent-reset:0.039 / 0.039秒] [时间:用户= 0.04 sys = 0.00,真实= 0.04秒]
@ 2011-07-20 02:11:20 <登记/> [GC [1 CMS-initial-mark:4019034K(7340032K)] 4301238K(10171200K),0.0308450 secs] [次:用户= 0.03 sys = 0.00,real = 0.03 secs]
@ 2011-07- 20 02:11:30
[CMS-concurrent-mark:10.304 / 10.307 secs] [时间:用户= 20.48 sys = 0.11,实际= 10.31秒]
[CMS-concurrent-preclean:0.018 / 0.019 secs] [次:用户= 0.02 sys = 0.00,实际= 0.01秒]
@ 2011-07-20 02:11:35 <登记/>  CMS:因时间而中止预扫[CMS-并发 - 流产 - 预清洁:1.043 / 5.048秒]时间:用户= 1.03 sys = 0.00,实际= 5.05秒] [GC [YG占有率:282204 K(2831168 K)] [重新扫描(平行),0.0419560秒] [弱参考处理,0.0010880秒]
[1 CMS-remark:4019034K(7340032K)] 4301 238K(10171200K),0.0431480秒] [时间:用户= 0.07 sys = 0.01,实际= 0.05秒]
@ 2011-07-20 02:11:38
[CMS-concurrent-sweep:2.622 / 2.622秒] [时间:用户= 2.63 sys = 0.00,实际= 2.62秒]
[CMS-concurrent-reset:0.039 / 0.039秒] [时间:用户= 0.04 sys = 0.00,实际= 0.04秒]

2 个答案:

答案 0 :(得分:4)

尝试使用UseCMSInitiatingOccupancyOnly&amp; CMSInitiatingOccupancyFraction标志。使用这些标志启动CMS集合将根据占用率触发。 此外,可能有意义增加终身一代的规模。

答案 1 :(得分:3)

内存碎片怎么样?并发标记和扫描不会压缩内存,最终会变得非常碎片 - 所以尽管你有足够的总空间,但是你可能没有足够的空间来分配新对象; GC启动了。