When using weak or soft reference with a ReferenceQueue
when is the object really removed from memory? Do I have to call referancequeue.remove
or referancequeue.poll()
methods?
Example:
ReferenceQueue q = new ReferenceQueue();
WeakReference wr = new WeakReference(object, referenceQueue);
if (pr.isenqueued()) {
// do something
}
or do I have to following?
WeakReference weakref=null;
if ((weakref=q.removed())!=null) {
// do something
}