lua-users home
lua-l archive

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


Mauro wrote:
> On my computer (x86_64) this runs well. Using -m32 to generate 32 bit
> code recreates the freeze.

Thanks for your additional information. It's very interesting, also.


> If you read the
> definitions of the gc parameters, you will see that you are asking the
> collector to start whenever the memory grows over 100% of what's
> currently used.

Yes, that value of 100 or smaller is documented.

>From section 2.10 of Lua5.1 reference manual,
  > Values smaller than 1 mean the collector will not wait to start a new cycle

Though the manual doesn't say that the value of that range should not be
set or unsafe. It looks like very safe behavior that "the collector will
not wait to start a new cycle".

Because the GC of Lua5.1 is incremental GC, it can just return when it
will be infinite loop. And no one like it to loop infinitely. 
It is always treated as severe "show stopper" error, when your
application's scripting engine stops responding.

Some memory severe application can have a setting of "setpause" as 100 or
around, to let GC to not stop collecting. For that kind of application,
I can't say it's safe thing to call collectgarbage("step",n).


> If a collection cycle has just finished then it cannot reclaim any
> memory, and whatever threshold it wants to get under (probably a
> percentage of current), it cannot reach it. Thus it remains in the
> loop you have seen. Try using collectgarbage("setpause", 101) : it
> seems to fix things here.

It looks like that kind of way.

To escape from the loop in lua_gc() in the LUA_GCSTEP case, it needs some
GC work. Normally, if GC does some work, it will eventually reach the
threshold. But if GC collects all the garbage in one call to luaC_step(),
it will not take the process of add the amount of work, and instead,
reset the threshold using "setpause" value.
So it keeps looping in lua_gc(), while GC is very hard at work.

I think it's one way to go, to document in the manual about the safe
range of GC parameters.

Though it'll better to just return from collectgarbage("step") when the
GC completes one cycle. Because, I think no one have the impression that
one collectgarbage("step", n) will do more than collectgarbage("collect"),
but it can now.


Thanks,
Makoto Hamanaka <naraxx800@yahoo.co.jp>