lua-users home
lua-l archive

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


I've been trying to use collectgarbage( "step", n ) to advance the GC in
proportion to other storage that I'm allocating. However, I am finding that
I spend a significant percentage of my profiled time in the GC which
suggests that it is moving forward by more than I am expecting. Reviewing
the code, it looks to me like it always forces the GC to advance and
furthermore keeps it advancing on subsequent allocations since the threshold
will have been brought down close to the total number of bytes.

Some alternatives that I could imagine:

1. Add the step to g->totalbytes.

2. Alternatively, subtract the step from g->GCthreshold.

3. Or do what it does now, but then kick the threshold back up after
advancing the GC.

The third option is the only one that forces the GC to actually do some
work, but the logic to restore the threshold seems complicated.

Or am I just reading this wrong and my problem is actually that I'm
executing too big a step?

Mark