lua-users home
lua-l archive

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


> Could you point me, please, what am I missing here? Why aren't these
> objects collected when the only strong reference to them is a local
> variable or argument inside a dead coroutine?

An error in a coroutine does not unwind its stack (see [1]). This is
to allow you to debug the coroutine in case of errors. So, there is
a strong reference to the coroutine (as a key in table 'list'), and
the coroutine has a strong reference to the handle; nothing can be
collected.

(In other words, an error in a coroutine is somewhat similar to an
'yield', except that you cannot resume it again.)

The difference for the coroutine that runs to completion is that,
when the coroutine finishes, 'handle' goes out of scope.

[1] http://www.lua.org/manual/5.1/manual.html#lua_resume

-- Roberto