问题描述
在Java中(通过JMX)调用System.gc()
时,它将尽职地(试图)清理年轻一代.这通常效果很好.不过,我从未见过它试图清理终身制.这使我想到两个问题:
- 可以收集使用权的世代(即,这一代中是否确实存在垃圾,或者使用权的世代中的所有对象实际上仍具有对它们的实时引用)?
- 如果,可以收集终身代,可以通过System.gc()完成,还是有另一种方式(不太可能),或者我只需要等到我终身代人的空间用完了吗?
http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#other_considerations 指出,System.gc()触发了major
集合,即包括使用权. >
您是否发现GC日志中不是这种情况?
When invoking System.gc()
in java (via JMX), it will dutifully (attempt to) clean the young generation. This generally works very well. I have never seen it attempt to clean the tenured generation, though. This leads me to two questions:
- Can the tenured generation even be collected (i.e. is there actually garbage in this generation, or do all objects in the tenured generation actually still have live references to them)?
- If the tenured generation can be collected, can this be done via System.gc(), or is there another way to do it (unlikely), or will I simply have to wait until I run out of space in the tenured generation?
http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#other_considerations states that System.gc() triggers a major
collection, i.e. including tenured.
Have you seen this not to be the case in the GC logs?
这篇关于在Java中调用System.gc()会建议使用权的一代以及年轻一代的垃圾回收吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!