public abstract class FinalizeObject extends WeakReference<Object> implements com.gemstone.gnu.trove.TLinkable
Note that there is a significant performance impact on GC when using
Object.finalize() vs the approach below, so former should be removed
from all code and never used in product code. It also leads to significant
delays in GC itself leading to memory buildups.
Also note that this uses a WeakReference rather than a
PhantomReference. The reason is that PhantomReference is not
cleared when it is enqueued (at least in Java 7/8) so the referent remains
alive till it is explicitly cleared by the queue poller. This unnecessarily
increases the lifetime of the referent and can cause trouble if there is
a rapid increase of such objects. Using a WeakReference avoids this
where the referent will be cleared as before it is enqueued and will
otherwise behave similar to a PhantomReference assuming the
referent is not overriding the finalize method too.
| Modifier and Type | Class and Description |
|---|---|
static interface |
FinalizeObject.BatchFinalize
Interface that finalizers (extensions of FinalizeObject) can implement to
indicate batching of finalization where possible e.g.
|
static class |
FinalizeObject.State
Simple wrapper class to share state across the base object and
FinalizeObject. |
| Modifier | Constructor and Description |
|---|---|
protected |
FinalizeObject(Object referent,
boolean server) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
clearAll() |
static void |
clearFinalizationQueues() |
protected abstract void |
clearThis() |
protected abstract boolean |
doFinalize()
The finalizer method for the object for post GC cleanup.
|
static FinalizeHolder |
getClientHolder() |
abstract FinalizeHolder |
getHolder() |
com.gemstone.gnu.trove.TLinkable |
getNext() |
com.gemstone.gnu.trove.TLinkable |
getPrevious() |
static FinalizeHolder |
getServerHolder() |
void |
setNext(com.gemstone.gnu.trove.TLinkable linkable) |
void |
setPrevious(com.gemstone.gnu.trove.TLinkable linkable) |
enqueue, get, isEnqueuedprotected FinalizeObject(Object referent, boolean server)
public static FinalizeHolder getServerHolder()
public static FinalizeHolder getClientHolder()
public static void clearFinalizationQueues()
public final void clearAll()
public final com.gemstone.gnu.trove.TLinkable getNext()
getNext in interface com.gemstone.gnu.trove.TLinkablepublic final com.gemstone.gnu.trove.TLinkable getPrevious()
getPrevious in interface com.gemstone.gnu.trove.TLinkablepublic final void setNext(com.gemstone.gnu.trove.TLinkable linkable)
setNext in interface com.gemstone.gnu.trove.TLinkablepublic final void setPrevious(com.gemstone.gnu.trove.TLinkable linkable)
setPrevious in interface com.gemstone.gnu.trove.TLinkablepublic abstract FinalizeHolder getHolder()
protected abstract void clearThis()
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.