lua-users home
lua-l archive

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


> Hi all.
> I work on the project for game, that including Lua as a scripting system.
> When user change game map, I call
> lua_gc(state, LUA_GCCOLLECT) (twice) and some Lua object's (userdata) must
> be collected. But it isn't.
> I discoverd, that if Lua create any table after garbage collection cycle,
> all work good. But I have to collect objects in time when I call lua_gc.
> Can I call lua_gc with "force" instruction?

lua_gc(state, LUA_GCCOLLECT) (twice) should be "force" enough. If a
userdata is not accessible, a single call to lua_gc(state, LUA_GCCOLLECT)
must either call its finalizer or, if it does not have
a finalizer, collect it. (If it has a finalizer, the second call
to lua_gc should collect it, after the first call ran the finalizer.)

-- Roberto