42
Another way applications can interact with garbage collection is by invoking full garbage collections explicitly, such as through the System.gc() call. These calls force major collection, and inhibit scalability on large systems. The performance impact of explicit garbage collections can be measured by disabling explicit garbage collections using the flag -XX:+DisableExplicitGC.
One of the most commonly encountered uses of explicit garbage collection occurs with RMI's distributed garbage collection (DGC). Applications using RMI refer to objects in other virtual machines. Garbage can't be collected in these distributed applications without occasional local collection, so RMI forces periodic full collection.
Mike Gershman
SCJP 1.4, SCWCD in process
Originally posted by Mike Gershman:
It sound to me like the individual objects will be garbage collected in the second GC pass. In the firsct GC pass, the HashMap is garbage collected. If it contained the only references to the objects in question, that leaves them available for garbage collection on the next pass.
So you'd call System.gc() twice.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Mike Gershman
SCJP 1.4, SCWCD in process
how can i verify an object is collected for garbage?
Mike Gershman
SCJP 1.4, SCWCD in process
Originally posted by Mike Gershman:
Just add a weak reference to the object and later check if it's null
Mike Gershman
SCJP 1.4, SCWCD in process
Originally posted by Mike Gershman:
"unchecked call to WeakReference(T) as a member of the raw type java.lang.ref.WeakReference
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Consider Paul's rocket mass heater. |