[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Memory leak in Lua 5.0
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 02 Oct 2002 16:17:49 -0300
> 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?
Well, if not known, at least it was predictable ;-) I mean, this is not
a bug in the implementation, but in the specification.
As it is now, C code can keep direct pointers to Lua "threads" (or
"stacks"). That means that threads are not garbage collected at all; C
must explicitly "close" them. In the implementation of coroutines, we
represent threads in Lua as userdata, and we use their GC metamethod to
close the corresponding thread. But of course such scheme does not work
for circular references.
Maybe we will have to change that, making threads collectable.
-- Roberto