lua-users home
lua-l archive

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


Dear Patrick,

lua_settop(L, 0);
lua_newtable(L);
lua_replace(L, LUA_GLOBALSINDEX);
lua_pushvalue(L, LUA_GLOBALSINDEX);
lua_replace(L, LUA_ENVIRONINDEX);
lua_newtable(L);
lua_replace(L, LUA_REGISTRYINDEX);
lua_gc(L, LUA_GCCOLLECT, 0);

Your code just create new empty tables, replace the GT and registry
with them. This will destroy the base library & my extension what loaded 
by luaI_openlib .

------------------				 
Aurora
2010-04-13

-------------------------------------------------------------
From:Patrick Donnelly
Date:2010-04-13 10:09:28
To:Lua list
CC:
Subject:Re: Re: Help ! A problem with the memroy

On Mon, Apr 12, 2010 at 10:00 PM, Aurora <bravefly@gmail.com> wrote:
> Dear Sam,
>
> "Possibly, it's because the last file created global vars, and the gc
> doesn't know that they will never be used again.  "
>
> That's it.   You are so bright.
> The method you give is  ok. But I need to do it in the C source code of lua, not in lua.
> I want to know how could I delete all the objects and memory  produced by the last lua file.
> such as:
>        luaF_close(L, L->top);
>        free_reg_table(L, h);
>        free_global_table(L, h);
>        free_all_rootgc(L, h);
>        free_all_str(L, h);


/* From main Lua state */
lua_settop(L, 0);
lua_newtable(L);
lua_replace(L, LUA_GLOBALSINDEX);
lua_pushvalue(L, LUA_GLOBALSINDEX);
lua_replace(L, LUA_ENVIRONINDEX);
lua_newtable(L);
lua_replace(L, LUA_REGISTRYINDEX);
lua_gc(L, LUA_GCCOLLECT, 0);


-- 
- Patrick Donnelly