Class MemoryCleaner

java.lang.Object
io.github.jwharm.javagi.interop.MemoryCleaner

public 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 GLib.free(MemorySegment) or a specialized method.

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