WeakPointerScope

public class WeakPointerScope

A minimalist pointer scope only keeping weak references to its elements.

As opposed to ERROR(/org.bytedeco.javacpp.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.

Public Constructors

Public Methods

void
attach (Pointer pointer)
Attach a pointer to this scope.
synchronized void
void
detach (Pointer pointer)
Detach a pointer from this scope.

Inherited Methods

Public Constructors

public WeakPointerScope ()

Public Methods

public void attach (Pointer pointer)

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 pointer was already attached to this scope, this method has no effect.

Parameters
pointer pointer to attach
Throws
IllegalStateException if that scope has already been closed

public synchronized void close ()

public void detach (Pointer pointer)

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 pointer is not attached to this scope, this method has no effect.

Parameters
pointer pointer to detach
Throws
IllegalStateException if that scope has already been closed