Package org.bytedeco.javacpp
Class Pointer.DeallocatorReference
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.PhantomReference<Pointer>
-
- org.bytedeco.javacpp.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 java.lang.ref.PhantomReference<Pointer> implements Pointer.Deallocator, Pointer.ReferenceCounter
A subclass ofPhantomReference
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 callSystem.gc()
when that amount reachesPointer.maxBytes
, and implements reference counting with anAtomicInteger
count.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) long
bytes
(package private) java.util.concurrent.atomic.AtomicInteger
count
(package private) Pointer.Deallocator
deallocator
(package private) static Pointer.DeallocatorReference
head
(package private) Pointer.DeallocatorReference
next
(package private) Pointer.DeallocatorReference
prev
(package private) static long
totalBytes
(package private) static long
totalCount
-
Constructor Summary
Constructors Constructor Description DeallocatorReference(Pointer p, Pointer.Deallocator deallocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
add()
void
clear()
int
count()
void
deallocate()
boolean
release()
(package private) void
remove()
void
retain()
java.lang.String
toString()
-
-
-
Field Detail
-
head
static volatile Pointer.DeallocatorReference head
-
prev
volatile Pointer.DeallocatorReference prev
-
next
volatile Pointer.DeallocatorReference next
-
deallocator
Pointer.Deallocator deallocator
-
totalBytes
static volatile long totalBytes
-
totalCount
static volatile long totalCount
-
bytes
long bytes
-
count
java.util.concurrent.atomic.AtomicInteger count
-
-
Constructor Detail
-
DeallocatorReference
DeallocatorReference(Pointer p, Pointer.Deallocator deallocator)
-
-
Method Detail
-
add
final void add()
-
remove
final void remove()
-
clear
public void clear()
- Overrides:
clear
in classjava.lang.ref.Reference<Pointer>
-
deallocate
public void deallocate()
- Specified by:
deallocate
in interfacePointer.Deallocator
-
retain
public void retain()
- Specified by:
retain
in interfacePointer.ReferenceCounter
-
release
public boolean release()
- Specified by:
release
in interfacePointer.ReferenceCounter
-
count
public int count()
- Specified by:
count
in interfacePointer.ReferenceCounter
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-