The memory of structs/unions (not GObjects) is automatically released when the Java Proxy object gets garbage-collected. However, multiple Proxy objects referring to the same memory address would cause a double-free. This has been fixed by implementing a simple reference-counting scheme. Every new Proxy object for a memory address increases the refcount. And when a Proxy object is finalized, the refcount is decreased. Only when the refcount becomes 0, the memory is reclaimed.
The memory of structs/unions (not GObjects) is automatically released when the Java Proxy object gets garbage-collected. However, multiple Proxy objects referring to the same memory address would cause a double-free. This has been fixed by implementing a simple reference-counting scheme. Every new Proxy object for a memory address increases the refcount. And when a Proxy object is finalized, the refcount is decreased. Only when the refcount becomes 0, the memory is reclaimed.