[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setting a global with lua_Object
- From: Renato Cerqueira <rcerq@...>
- Date: Fri, 15 Sep 2000 00:26:41 -0300
At 14:08 14/09/2000 -0400, you wrote:
That looks like a better way to load the table, but still doesn't really
answer my question. I need to somehow force that table to be garbage
collected when the class is deleted (in the destructor). Without a
reference to the table (the global variable), how do you release it?
Ok. In your constructor, you should lock a reference to
the Lua table (lua_Object), using the lua_ref function.
In the destructor, you should unlock that reference using the
lua_unref function.
If there isn't any other reference to the table, it should be
collected in the next garbage collection cycle.
(see http://www.tecgraf.puc-rio.br/lua/manual/manual.html#5.8)
Then, if you really want to force a gargabe collection cycle,
you can use the lua_collectgarbage function.
(see http://www.tecgraf.puc-rio.br/lua/manual/manual.html#5.3)
Regards,
Renato
-----------------------------------------------
Renato Cerqueira, Ph.D.
Research Staff Member, Tecgraf/PUC-Rio
email: rcerq@tecgraf.puc-rio.br
http://www.tecgraf.puc-rio.br/~rcerq