Class MemoryCleaner

java.lang.Object
io.github.jwharm.cairobindings.MemoryCleaner

public final class MemoryCleaner extends Object
This class keeps a cache of all memory addresses for which a Proxy object was created (except for GObject instances; those are handled in the InstanceCache).

When a new Proxy object is created, the reference count in the cache is increased. When a Proxy object is garbage-collected, the reference count in the cache is decreased. When the reference count is 0, the memory is released using the specified free-func.

When ownership of a memory address is passed to native code, the cleaner will not free the memory. Ownership is enabled/disabled with takeOwnership(MemorySegment) and yieldOwnership(MemorySegment).