lua-users home
lua-l archive

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

Graham Wakefield wrote:
Another thought - is it possible to get some kind of callback from a lua_State when it is collected? This would allow me to free C resources attached to it and prevent my memory leak. Something like a __gc method for states created via lua_newthread.

Yes - create a userdata with a __gc metamethod, then put it
(the userdata) into the lua_State's registry under some unique
key (e.g., the userdata itself).