Skip to content

Ffi

Zune's zune.ffi with pooled native memory.

Zune caches pointer objects by address. zune.ffi.free returns the memory to the allocator but leaves the dead pointer object in that cache until the garbage collector removes it, and a native library that later receives the same address from malloc (a libopus decoder, a libdave session) is handed the dead object and fails with "unavailable address". Memory freed here therefore goes back to a pool that alloc and dupe reuse, so it never returns to the allocator and no dead object ever shadows a live address. The pool holds at most the peak amount allocated at once.