Weak References

Y Srinivas Ramakrishna Y.S.Ramakrishna at Sun.COM
Sun Apr 27 22:21:36 PDT 2008


Hi Keith --

> If we are seeing a huge build up of weak references:
> 
> sun/rmi/transport/WeakRef =>
>       1654973  1644293  10680       0      0 Total
>        794333   783888  10445       0      0 => com/sas/metadata/remote/MdObjectListImpl
>        194966   194966      0       0      0 => com/sas/metadata/remote/impl/PropertyImpl
>       192165   192165      0       0      0 => com/sas/services/information/metadata/OMRProperty
> 
> When does the GC algorithm decide to collect? Is there something that 
> can be done programatically to collect earlier?

When a GC finds that the referent of a WeakReference is not strongly reachable,
then the WeakReference is cleared, the referent is collected and the
WeakReference's queue (if any) is notified. The WeakReference itself is
collected only if and when it becomes strongly unreachable.

> 
> I assume GC will not collect until the weak references are "dead", 
> i.e. the referents are available for GC since no strong refs are 
> pointing at the referent?
> 
> Any guidance appreciated.

But, I do not know anything about how exactly RMI makes use of WeakReferences.

-- ramki




More information about the hotspot-gc-use mailing list