什么触发Java中的完整垃圾回收? [英] What triggers a full garbage collection in Java?

查看:139
本文介绍了什么触发Java中的完整垃圾回收?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



显而易见的是:




  • 用完旧gen

  • 用完perm gen

  • 调用System.gc()



其他导致完整gc的情况如何?特别是:


  • 在Survivor Space中没有足够的可用空间从Eden复制对象。

  • 轻微集合不能处理新对象的分配率(不知道如何)。


我正在运行Sun Java 1.6并使用Concurrent Mark-Sweep和ParNew for new gen。

解决方案

我观察到触发完整GC的另一种情况在Ubuntu上使用Concurrent Mark-Sweep的Java Hotspot VM 1.6 64bit:如果-XX:PermSize值不等于-XX:MaxPermSize(例如更小),当Java需要扩展PermGen时偶尔发生Full GC(即使它不需要分配比MaxPermSize更多的内存)。
因此将-XX:PermSize和-XX:MaxPermSize设置为相同似乎是个好主意。


I'm wondering what are the exact situations that trigger Full Garbage Collection in Java.

The obvious ones are:

  • Running out of old gen
  • Running out of perm gen
  • Calling System.gc()

What about other cases that cause full gc? Particularly:

  • Not having enough free space in Survivor Space to copy objects from Eden.
  • Minor collections not being able to cope with allocation rate of new objects (don't know how though).

I'm running Sun Java 1.6 and using Concurrent Mark-Sweep and ParNew for new gen.

解决方案

I've observed one more situation that triggers a full GC in Java Hotspot VM 1.6 64bit on Ubuntu, using Concurrent Mark-Sweep:

If -XX:PermSize value does not equal to -XX:MaxPermSize (e.g. is smaller), an occasional Full GC happens when java needs to expand the PermGen (even though it does not need to allocate more memory than MaxPermSize). So setting -XX:PermSize and -XX:MaxPermSize to be the same seems like a good idea.

这篇关于什么触发Java中的完整垃圾回收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆