Use a PhantomReference for releasing native FFI memory, to ensure they don't get run until after the object has been finalized and is guaranteed to be no longer reachable.