[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: closure runs with garbage collected upvalue ?
- From: Gregory Bonik <gregory@...>
- Date: Fri, 16 Sep 2011 17:18:38 +0400
Gaspard Bucher wrote:
> I do not have any finalizers in the userdata.
I think it doesn't really matter. The fact is that garbage collector
sometimes doesn't collect all garbage in one cycle. One possible cause
are finalizers. In your case, it's probably a complicated dependency
graph with circular references. (For curiosity's sake, try to run
collectgarbage() multiple times instead of one and see if the program
Combined with weak tables, this can be dangerous. I believe that one
should not rely on GC to remove entries from weak tables (probably
except the case of "direct cache" when userdata are values in a weak
table), and remove these entries manually.
I think this shouldn't be considered a bug in Lua, but rather a feature
of its garbage collector and weak table semantics.