lua-users home
lua-l archive

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


On Friday 09, Bogdan Marinescu wrote:
> I can't test right now, but it might be here:
>
> static void script_run_gc(script_info_t *info, size_t need)
> {
> ...............................
> #else
> 	size_t step_size = ((need >> 10) + 1) * GC_STEP_SIZE_MUL;
> 	size_t old_memused = info->memused;
> 	int cycle_count = 0;
> 	do {
> 		if(lua_gc(info->L, LUA_GCSTEP, step_size)) {
> 			/* only allow completing the last cycle and starting a new cycle. */
> 			if((++cycle_count) > 1) break;
> 		}
> 	} while((info->memused + need) >= info->max_memused);
> 	//printf("freed=%zd, need=%d\n", (old_memused - info->memused),need);
> #endif
> }
That looks like the same step collection code as in the lua_memlimit program.

> "if(lua_gc(info->L, LUA_GCSTEP, step_size))" <- if lua_gc returns
> false, it's possible that the do...while block runs forever. Did you
> try with step collection or full collection?
lua_gc() returns false unless the step collection request finished a 
collection cycle.  If "lua_gc(info->L, LUA_GCSTEP, step_size)" is called 
until it returns true, it should complete a full collection.

I will take a closer look at it tomorrow.  There are a few loops inside lua_gc 
and luaC_step that might be causing this problem.

-- 
Robert G. Jakabosky