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()
.
Thanks,
After a Full GC, which a System.gc() may or may not trigger,
In short, the only time System.gc() won't change objects between generations is when
if this could be another reason why calling System.gc() is evil
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.
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.
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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.