lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I noticed a problem in Lua 5.0's garbage collection.
If a coroutine has a reference to a table, and the
table has a reference back to the coroutine, they
will not be garbage collected even when they become
unreachable.

Is this a known bug?

Here's a simple demo.

----
function test()
    local t = {}
    local f = function()
        print(t)
    end
    t.f = coroutine.create(f)
end

collectgarbage()
print(gcinfo())

for i=1,100000 do test() end

collectgarbage()
print(gcinfo())
---

--Jeff Petkau