lua-users home
lua-l archive

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


> -----Message d'origine-----
> De : lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] De la part de Francesco Abbate
> Envoyé : lundi 2 août 2010 13:58
> À : lua@bazar2.conectiva.com.br
> Objet : bug in Lua 5.1.4 with GC, userdata and fenv
> 
> Hi all,
> 
> I hope someone can help me with this bug or otherwise explain me what
> I'm doing wrong.

My guess is this isn't a Lua bug. Your "plot" and "line" objects most likely get collected during the same cycle, since when the "plot" becomes unreachable, its "lines" become unreachable too at the same time. Doc says that during a collection cycle, userdata are collected in reverse creation order, so it is the expected behavior.

What I would do to solve this is store all lines belonging to a plot in some table, but instead of this being the plot's environment, use your plots as weak keys to these tables in an ephemeron table stored in the registry, thus causing plot finalizers to be called before the lines are destroyed (see §2.5.2).


Benoit.