Class WeakPointerScope
java.lang.Object
org.tensorflow.internal.WeakPointerScope
- All Implemented Interfaces:
AutoCloseable
A minimalist pointer scope only keeping weak references to its elements.
As opposed to PointerScope, instances of this class will not
prevent the garbage collector to free the memory of a pointer that is no longer reachable, even
if it has been attached to the scope.
When the scope is closed, all pointers that are still valid will be automatically deallocated while those already garbage-collected will be ignored.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
WeakPointerScope
public WeakPointerScope()
-
-
Method Details
-
attach
Attach a pointer to this scope.Pointers attached to the scope will be automatically freed once the scope is closed, unless they have been already released by the garbage collector
It this
pointerwas already attached to this scope, this method has no effect.- Parameters:
pointer- pointer to attach- Throws:
IllegalStateException- if that scope has already been closed
-
detach
Detach a pointer from this scope.Detaching a pointer from the scope will prevent its memory to be freed when closing the scope.
If this
pointeris not attached to this scope, this method has no effect.- Parameters:
pointer- pointer to detach- Throws:
IllegalStateException- if that scope has already been closed
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-