On 3/27/14 7:55 PM, demetri wrote: > > > Could you confirm that by "unanchored FFI cdata" you mean native > arrays which are deallocated randomly by non-Lua part? > > > > > -- Case 3 (unanchored return of ffi.new()) > local function baz () > local x = ffi.new(whatever) > -- do some stuff to x > return x > -- oops! nothing references the memory from ffi.new when local x > goes out > -- of scope! > end > > So are you saying that if - using your example - I do: local x = baz() that x can get collected out from under me? I don't think that's right. I've always relied on cdata being collected when they're not in any GC roots.