[英]Does calling System.gc() reset the statistical data for generational collection?
In other words: 换一种说法:
I need to know if after calling System.gc()
object instances (that are not collected) are distributed between generations in the same way as before calling System.gc()
. 我需要知道在调用
System.gc()
对象实例(未收集)是否以与调用System.gc()
之前相同的方式分布在各代之间。
Thanks, 谢谢,
After a Full GC, which a System.gc() may or may not trigger, 在完成GC之后,System.gc()可能会触发也可能不会触发,
In short, the only time System.gc() won't change objects between generations is when 简而言之,System.gc()不会在各代之间更改对象的唯一时间是何时
if this could be another reason why calling System.gc() is evil
如果这可能是调用System.gc()是邪恶的另一个原因
Mostly because it hurts performance and you gain very little in return. 主要是因为它损害了性能,您获得的回报却很小。 Note: the RMI can trigger a full collection periodically to ensure distributed objects are cleaned up but it tries to keep this to a minimum.
注意:RMI可以定期触发完整的收集,以确保清除分布式对象,但是它试图将其保持在最低水平。
First of all, System.gc()
is only a hint to the JVM that you want a GC, it might not trigger one (if using -XX:+DisableExplicitGC
with Hotspot for example), and you should not rely on it doing anything -- the JVM usually knows better anyway. 首先,
System.gc()
只是向JVM提示您想要GC,它可能不会触发(例如,如果将-XX:+DisableExplicitGC
与Hotspot一起使用),则您不应依赖它执行任何操作-JVM通常反而是更好。
If it does trigger a GC, then it's just like any other GC, and objects might get promoted from the young to the old generation if they satisfy the criteria (enough generations spent in the survivor spaces for example). 如果它确实触发了GC,则它与任何其他GC一样,如果满足条件(例如,足够的世代在幸存者空间中使用),则对象可能会从年轻一代升级为老一代。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.