[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua OO and garbage collector
- From: "Wim Couwenberg" <wcou@...>
- Date: Fri, 30 Jan 2004 16:48:36 +0100
Another thing:
> function Square:delete()
> self=nil
> collectgarbage()
> return self
> end
The "self = nil" doesn't do much gc-wise, as the caller will probably still
have a reference to the same object. So the "collectgarbage" call can not
yet collect "self"! In the example your "local moo" references the object
troughout the call to delete. Insert a collectgarbage() just before the
second gcinfo call and see what happens.
> print (gcinfo());
> moo=moo:delete();
-- insert collectgarbage() here
> print (gcinfo());
> moo:show();
--
Wim