pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: gc.c,v 1.190 2002/11/25 00:57:43 nilsson Exp $ + || $Id: gc.c,v 1.191 2003/01/12 17:25:39 mast Exp $   */      #include "global.h"      struct callback *gc_evaluator_callback=0;      #include "array.h"   #include "multiset.h"   #include "mapping.h"   #include "object.h"
pike.git/src/gc.c:24:   #include "constants.h"   #include "interpret.h"   #include "bignum.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.190 2002/11/25 00:57:43 nilsson Exp $"); + RCSID("$Id: gc.c,v 1.191 2003/01/12 17:25:39 mast Exp $");      /* Run garbage collect approximately every time    * 20 percent of all arrays, objects and programs is    * garbage.    */      #define GC_CONST 20   #define MIN_ALLOC_THRESHOLD 1000   #define MAX_ALLOC_THRESHOLD 10000000   #define MULTIPLIER 0.9
pike.git/src/gc.c:2388:    if (!p) break;    }    }       CALL_AND_UNSET_ONERROR(tmp);   }      int do_gc(void)   {    double tmp; -  ptrdiff_t objs, pre_kill_objs; +  ptrdiff_t start_num_objs, objs, pre_kill_objs;    double multiplier;   #ifdef PIKE_DEBUG   #ifdef HAVE_GETHRTIME    hrtime_t gcstarttime = 0;   #endif    unsigned destroy_count, obj_count;    ONERROR uwp;   #endif       if(Pike_in_gc) return 0;
pike.git/src/gc.c:2440: Inside #if defined(PIKE_DEBUG)
  #endif    }    if(num_objects < 0)    Pike_fatal("Panic, less than zero objects!\n");   #endif       last_gc=TIME(0);       multiplier=pow(MULTIPLIER, (double) num_allocs / (double) alloc_threshold);    objects_alloced*=multiplier; -  objects_alloced += (double) num_allocs; +  objects_alloced += (double) num_allocs * (1.0 - multiplier);       objects_freed*=multiplier;    -  +  start_num_objs = num_objects; +     /* Thread switches, object alloc/free and any reference changes are    * disallowed now. */      #ifdef PIKE_DEBUG    delayed_freed = weak_freed = checked = marked = cycle_checked = live_ref = 0;    live_rec = frame_rot = 0;    if (gc_debug) {    unsigned n;    Pike_in_gc = GC_PASS_PRETOUCH;    n = gc_touch_all_arrays();
pike.git/src/gc.c:2783:       Pike_in_gc=0;    exit_gc();       /* It's possible that more things got allocated in the kill pass    * than were freed. The count before that is a better measurement    * then. */    if (pre_kill_objs < num_objects) objs -= pre_kill_objs;    else objs -= num_objects;    -  objects_freed += (double) objs; +  objects_freed += (double) objs * (1.0 - multiplier);    -  tmp=(double)num_objects; +  tmp=(double)start_num_objs;    tmp=tmp * GC_CONST/100.0 * (objects_alloced+1.0) / (objects_freed+1.0);       if(alloc_threshold + num_allocs <= tmp)    tmp = (double)(alloc_threshold + num_allocs);       if(tmp < MIN_ALLOC_THRESHOLD)    tmp = (double)MIN_ALLOC_THRESHOLD;    if(tmp > MAX_ALLOC_THRESHOLD)    tmp = (double)MAX_ALLOC_THRESHOLD;   
pike.git/src/gc.c:2807:       num_allocs=0;      #ifdef PIKE_DEBUG    UNSET_ONERROR (uwp);    if(GC_VERBOSE_DO(1 ||) t_flag)    {   #ifdef HAVE_GETHRTIME    fprintf(stderr,    "done (freed %"PRINTPTRDIFFT"d of %"PRINTPTRDIFFT"d things), %ld ms.\n", -  objs, objs + num_objects, (long)((gethrtime() - gcstarttime)/1000000)); +  objs, start_num_objs, (long)((gethrtime() - gcstarttime)/1000000));   #else    fprintf(stderr,    "done (freed %"PRINTPTRDIFFT"d of %"PRINTPTRDIFFT"d things)\n", -  objs, objs + num_objects); +  objs, start_num_objs);   #endif    }    if (max_gc_frames > max_tot_gc_frames) max_tot_gc_frames = max_gc_frames;    tot_cycle_checked += cycle_checked;    tot_live_rec += live_rec, tot_frame_rot += frame_rot;   #endif      #ifdef ALWAYS_GC    ADD_GC_CALLBACK();   #else