Class AbstractNativeReference
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Direct Known Subclasses:
AbstractImmutableNativeReference,RocksMutableObject
public abstract class AbstractNativeReference extends java.lang.Object implements java.lang.AutoCloseableAbstractNativeReference is the base-class of all RocksDB classes that have a pointer to a native C++rocksdbobject.AbstractNativeReference has the
dispose()method, which frees its associated C++ object.This function should be called manually, however, if required it will be called automatically during the regular Java GC process via
finalize().Note - Java can only see the long member variable (which is the C++ pointer value to the native object), as such it does not know the real size of the object and therefore may assign a low GC priority for it; So it is strongly suggested that you manually dispose of objects when you are finished with them.
-
-
Constructor Summary
Constructors Constructor Description AbstractNativeReference()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract voidclose()Frees the underlying C++ objectvoiddispose()Deprecated.Instead useclose()protected voidfinalize()Deprecated.You should not rely on GC of Rocks objects, and instead should either callclose()manually or make use of some sort of ARM (Automatic Resource Management) such as Java 7's try-with-resources statementprotected abstract booleanisOwningHandle()Returns true if we are responsible for freeing the underlying C++ object
-
-
-
Method Detail
-
isOwningHandle
protected abstract boolean isOwningHandle()
Returns true if we are responsible for freeing the underlying C++ object- Returns:
- true if we are responsible to free the C++ object
- See Also:
dispose()
-
close
public abstract void close()
Frees the underlying C++ objectIt is strong recommended that the developer calls this after they have finished using the object.
Note, that once an instance of
AbstractNativeReferencehas been disposed, calling any of its functions will lead to undefined behavior.- Specified by:
closein interfacejava.lang.AutoCloseable
-
dispose
@Deprecated public final void dispose()
Deprecated.Instead useclose()
-
finalize
@Deprecated protected void finalize() throws java.lang.ThrowableDeprecated.You should not rely on GC of Rocks objects, and instead should either callclose()manually or make use of some sort of ARM (Automatic Resource Management) such as Java 7's try-with-resources statementSimply callsdispose()to free any underlying C++ object reference which has not yet been manually released.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-