Class JNIReference
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.WeakReference<java.lang.Object>
-
- com.avpkit.ferry.JNIReference
-
public final class JNIReference extends java.lang.ref.WeakReference<java.lang.Object>
Returned byIBuffer.getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)for users that want to explicitly manage when the returnedByteBufferis released.This class creates a
WeakReferencethat 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 returnByteBufferobjects, there is no equivalent of delete(), so this object can be used if you want to explicitly control when theByteBuffer's underlying native memory is freed.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Explicitly deletes the underlying native storage used by the object this object references.java.lang.StringtoString()Creates a string representation of this reference.
-
-
-
Method Detail
-
delete
public void delete()
Explicitly deletes the underlying native storage used by the object this object references. The underlying native object is now no long valid, and attempts to use it could cause unspecified behavior.
-
toString
public java.lang.String toString()
Creates a string representation of this reference. If the underlying object this reference points to has been deleted, then "native" will be zero. IfJNIMemoryManager.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.
- Overrides:
toStringin classjava.lang.Object
-
-