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.

When a new Proxy object is created, a Cleaner is attached to it. When the Proxy object is garbage-collected, the memory is released using the specified free-func.

When ownership of a memory address belongs elsewhere, the cleaner must not free the memory. Ownership is enabled/disabled with takeOwnership(MemorySegment) and yieldOwnership(MemorySegment).