mlua icon indicating copy to clipboard operation
mlua copied to clipboard

Feature Request #2: Support explicitly closing Lua VMs from Lua instance directly and/or add a Lua::strong_count API

Open cheesycod opened this issue 8 months ago • 2 comments

E.g. using lua_close. Following a close operation, safety could (probably) be ensured by disallowing any Lua VM operations whatsoever.

Right now you need to drop all references to Lua VM to do so.

Even if a explicit close method is not possible, it would be nice for mlua to at least expose a strong count api for debugging (I actually had to fork mlua and add Lua::strong_count() to track down where I'm leaking RawLua handles). It’d also be nice if mlua had a feature flag to block cloning of Lua at compile time

Lastly, would it be possible to make things like WeakLua::state etc not panic if the Lua VM is destroyed somehow and instead return an error (and would doing so be beneficial?)

cheesycod avatar May 02 '25 02:05 cheesycod

Upon further thought, I think just exposing strong count would solve this issue entirely (the debug process at least would be solved)

cheesycod avatar May 05 '25 00:05 cheesycod

Is there any update here regarding a close and/or strong count API

cheesycod avatar Jun 05 '25 22:06 cheesycod