lua-users home
lua-l archive

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


On 2020/12/16 2:38, André Henriques wrote:
> On 2020/12/13 10:39, nerditation wrote:
> [...]
> I have little knowledge about garbage collectors. Does anyone know why the
> allocated function argument objects do not (or barely) affect the gc? Is this
> such and edge case that it is not worth the trouble to be dealt with? That is
> not a flaw in my opinion, I am asking just out of curiosity =].
> 
> André Henriques
> 

well, it turns out it's not because gc is not triggered, but it's a interesting
interaction between you testing methodology and the default gc parameters.

since all the new objects are created with finalizers, the gc earns many "credits"
by running finalizers, but it takes more and more "steps" between gc pauses.
the to-be-finalized object list gets longer and longer for subsequent gc cycles.

usually, when an application reaches somewhat steady state, the gc will catch up.
if your application must create many short lived objects, considering switching
to the generational gc. but you should only tweak the gc corresponding to
measurements done in real scenarios.

btw, per my testing, for your particular testing code, simply reduce the gc pause
a little bit (e.g. 190) and it will keep the memory usage reasonably low. don't
ask me how and why, I don't really understand the gc algorithm. I just tinkered
with the code a bit inside a debugger.