lua-users home
lua-l archive

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


>>>
Try the opposite approach, make a.b be a Lua reference, so that when a
is collected/deleted, you don't automatically delete its b sub-object.
<<<

So if I do that, I'm back to the point where b leaks.  Now, if I could somehow make it so that b collects when there are no references to b _and_ there are no references to 'a', then I'd be ok.  But I don't know how I'd go about doing that ...


On Wed, Sep 24, 2008 at 5:54 AM, Jerome Vuarand <jerome.vuarand@gmail.com> wrote:
2008/9/23 Matthew Armstrong <turkeypotpie@gmail.com>:
> Adding a copy (or clone) method is entirely doable (I've actually done so
> already).  The problem is, we have a rather large code base that depends on
> this type of code already:
>
> b = a.b
>
> Right now, a is never reclaimed, so we have a (bad) leak.  If I fix the leak
> so 'a' is reclaimed, it will cause crashes all over the place, because b
> becomes invalid after collection.
>
> It would be very difficult to track down all these cases and replace a.b
> with a.b:clone(), or whatever.  That's why I want to override the behavior
> and have it "just work".

Try the opposite approach, make a.b be a Lua reference, so that when a
is collected/deleted, you don't automatically delete its b sub-object.