Branch: Tag:

2012-07-06

2012-07-06 17:12:18 by Martin Stjernholm <mast@lysator.liu.se>

Do not let short disablements of the gc affect the gc intervals.

The gc interval is now properly saved and restored. Before this, brief
gc disablements could lead to alloc_threshold being set to the
minimum, which then could lower the max threshold calculation so that
the next gc interval could be unnaturally short through the
GARBAGE_MAX_INTERVAL strategy.

584:    SIMPLE_BAD_ARG_ERROR ("Pike.gc_parameters", 1,    "integer in the range -1..1 for 'enabled'");    if (gc_enabled != set->u.integer) { -  if (gc_enabled > 0) -  gc_enabled = set->u.integer; -  else { -  gc_enabled = 1; -  if (alloc_threshold == GC_MAX_ALLOC_THRESHOLD) -  alloc_threshold = GC_MIN_ALLOC_THRESHOLD; +  if (gc_enabled > 0) { +  /* Disabling automatic gc - save the old alloc_threshold and set it to +  * the maximum value to avoid getting gc_evaluator_callback added. */ +  saved_alloc_threshold = alloc_threshold; +  alloc_threshold = GC_MAX_ALLOC_THRESHOLD;    } -  +  else if (set->u.integer > 0) { +  /* Enabling automatic gc - restore the old alloc_threshold. If the +  * gc interval has gotten longer than it should be then the +  * multiplier calculation in do_gc should compensate. */ +  alloc_threshold = saved_alloc_threshold;    } -  +  gc_enabled = set->u.integer; +  }    }, {    get.type = T_INT;    get.subtype = NUMBER_NUMBER;