What triggers a full garbage collection in Java?(什么触发了 Java 中的完整垃圾回收?)
问题描述
我想知道在 Java 中触发 Full Garbage Collection 的确切情况是什么.
I'm wondering what are the exact situations that trigger Full Garbage Collection in Java.
显而易见的是:
- 老一代用完了
- 烫发用完了
- 调用 System.gc()
其他导致full gc的情况呢?特别是:
What about other cases that cause full gc? Particularly:
- 幸存者空间中没有足够的可用空间从伊甸园复制对象.
- 次要集合无法应对新对象的分配率(虽然不知道如何).
我正在运行 Sun Java 1.6 并使用 Concurrent Mark-Sweep 和 ParNew for new gen.
I'm running Sun Java 1.6 and using Concurrent Mark-Sweep and ParNew for new gen.
推荐答案
我观察到另外一种情况,在 Ubuntu 上的 Java Hotspot VM 1.6 64bit 中使用 Concurrent Mark-Sweep 触发完整 GC:
I've observed one more situation that triggers a full GC in Java Hotspot VM 1.6 64bit on Ubuntu, using Concurrent Mark-Sweep:
如果 -XX:PermSize 值不等于 -XX:MaxPermSize(例如更小),当 java 需要扩展 PermGen(即使它不需要分配比 MaxPermSize 更多的内存)时,偶尔会发生 Full GC.因此,将 -XX:PermSize 和 -XX:MaxPermSize 设置为相同似乎是个好主意.
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 中的完整垃圾回收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么触发了 Java 中的完整垃圾回收?
基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
