lua-users home
lua-l archive

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

On 3 Mar 2014, at 12:06, Felipe Ferreira da Silva <> wrote:

> 	// !!!Delete the chunk here!!!

The chunk itself will be subject to garbage collection after your first pcall, as there are no longer any references to it. However, it doesn't appear to be the chunk you're worried about, but rather the side effects of running the chunk, which I don't think there is a general solution (other than recreate the lua_State)

Obviously you could remove the global called function (bad name for a variable, but whatever) as follows

lua_setglobal(BWindowHandler->lua, "function");

but this won't undo any other side effects of the script, nor will it remove any other references to that value.

If re-opening the state is an option, I would consider that, else rewrite your user scripts to work more like modules and return tables of functions, rather than modifying the global state.