> The part you're missing is that the gc only keeps track of memory > allocated BY LUA. If you explicitly allocate additional memory, it > doesn't track that. Right, and I thought that this could be solved with a `size` arg to ffi.gc() which would tell the Lua GC the object's real size. But if I understand Mike's answer correctly, tracking memory this way wouldn't help much either because the GC cannot keep the pace with huge atomic allocations. It's the "keeping the pace" part that I don't understand. If the GC measures pressure in bytes (and not in number of objects or whatever), then the problem of keeping the pace with huge allocations is orthogonal to how those allocations are made -- so I was wondering if this problem wouldn't surface as well with Lua-only huge allocations coming from eg. file:read'*a', ffi.string() etc.