Using C++, lua5.1, luabind 0.7
Lua code:
-- allocates near 8Mb of memory
function fff()
local t = {}
for i = 1, 300000 do
table.insert(t, i)
end
return t
end
C++ code:
{
luaL_dostring(lua_state, "return fff()");
luabind::object obj(luabind::from_stack(ls, -1));
}
lua_gc(l_, LUA_GCCOLLECT, 0); // collect garbage
Result: Lua still have a 8Mb allocated memory. Garbage collection ignores that table object. It has references anywhere? But where? That table deallocates only on program exit (when "lua_close" function called). How to solve this problem?
Thank you.