
public final class JNIReference extends WeakReference<Object>
Buffer.getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)
for users that want to explicitly manage when the returned ByteBuffer
is released.
This class creates a WeakReference that Ferry classes will use for
memory management. We do this to avoid relying on Java's finalizer thread to
keep up and instead make every new native allocation first release any
unreachable objects.
Most times these objects are managed behind the scenes when you
call RefCounted.delete(). But when we return
ByteBuffer objects, there is no equivalent of
delete(), so this object can be used if you want to explicitly control
when the ByteBuffer's underlying native memory is freed.
| Modifier and Type | Method and Description |
|---|---|
void |
delete()
Explicitly deletes the underlying native storage used by
the object this object references.
|
static JNIMemoryManager |
getMgr()
Returns the
JNIMemoryManager we're using. |
String |
toString()
Creates a string representation of this reference.
|
clear, enqueue, get, isEnqueuedpublic static JNIMemoryManager getMgr()
JNIMemoryManager we're using.public void delete()
public String toString()
JNIMemoryManager.isMemoryDebugging() is true,
then the class and hashcode of the object this reference points to (or
used to point to) is also printed.
If the reference still points to an actual object, we will also print the contents of that object. It may return "null" in which case the underlying object is no longer reachable, but if native != 0, it means it has not yet been collected by Ferry.
Copyright © 2018 Humble Software. All rights reserved.