[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: PATCH: fixes bug with calling garbage collector from custom lua_Alloc
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Fri, 9 May 2008 03:12:26 -0700
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