diff --git a/doc/internal/gc.md b/doc/internal/gc.md index cf221c6a5..1d355fcb3 100644 --- a/doc/internal/gc.md +++ b/doc/internal/gc.md @@ -131,7 +131,9 @@ limit = (GC_STEP_SIZE / 100) * step_ratio ``` With default `step_ratio = 200` and `GC_STEP_SIZE = 1024`, the -limit is 2048 objects per step. +limit is 2048 objects per step. After each step, `gc_debt` is +decremented by the actual number of objects processed, so larger +steps repay more debt. When the gray stack is exhausted, the final marking phase re-marks the arena and global variables to catch objects created during diff --git a/src/gc.c b/src/gc.c index 24feb72a3..283d1dcdb 100644 --- a/src/gc.c +++ b/src/gc.c @@ -1332,7 +1332,7 @@ incremental_gc_step(mrb_state *mrb, mrb_gc *gc) break; } - gc->gc_debt -= (mrb_int)GC_STEP_SIZE; + gc->gc_debt -= (mrb_int)result; } static void