Class Pointer.DeallocatorReference
- All Implemented Interfaces:
Pointer.Deallocator, Pointer.ReferenceCounter
- Direct Known Subclasses:
Pointer.CustomDeallocator, Pointer.NativeDeallocator, Pointer.ProxyDeallocator
- Enclosing class:
Pointer
static class Pointer.DeallocatorReference
extends PhantomReference<Pointer>
implements Pointer.Deallocator, Pointer.ReferenceCounter
A subclass of
PhantomReference that also acts as a linked
list to keep their references alive until they get garbage collected.
Also keeps track of total allocated memory in bytes, to have it
call System.gc() when that amount reaches Pointer.maxBytes,
and implements reference counting with an AtomicInteger count.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) long(package private) AtomicInteger(package private) Pointer.Deallocator(package private) static Pointer.DeallocatorReference(package private) Pointer.DeallocatorReference(package private) Pointer.DeallocatorReference(package private) static long(package private) static long -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class PhantomReference
getMethods inherited from class Reference
clone, enqueue, isEnqueued, reachabilityFence, refersTo
-
Field Details
-
head
-
prev
-
next
-
deallocator
Pointer.Deallocator deallocator -
totalBytes
static volatile long totalBytes -
totalCount
static volatile long totalCount -
bytes
long bytes -
count
AtomicInteger count
-
-
Constructor Details
-
DeallocatorReference
DeallocatorReference(Pointer p, Pointer.Deallocator deallocator)
-
-
Method Details
-
add
final void add() -
remove
final void remove() -
clear
-
deallocate
public void deallocate()- Specified by:
deallocatein interfacePointer.Deallocator
-
retain
public void retain()- Specified by:
retainin interfacePointer.ReferenceCounter
-
release
public boolean release()- Specified by:
releasein interfacePointer.ReferenceCounter
-
count
public int count()- Specified by:
countin interfacePointer.ReferenceCounter
-
toString
-