lua-users home
lua-l archive

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

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();