[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to collect as much as possible with collectgarbage() ?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 10 Jul 2009 09:30:57 -0300
> Making it display bytes now could break a lot of existing code, but
> it's pretty easy to mod the code to add your own option...
For instance, collectgarbage("count") could return two values: one in K
and one in bytes. The change is simple:
lbaselib.c:
static int luaB_collectgarbage (lua_State *L) {
...
case LUA_GCCOUNT: {
int b = lua_gc(L, LUA_GCCOUNTB, 0);
lua_pushnumber(L, res + ((lua_Number)b/1024));
lua_pushnumber(L, res*1024 + b); <<<
return 2; <<<
}