pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:22:   #include "time_stuff.h"   #include "constants.h"   #include "interpret.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.46 2000/02/02 00:38:27 hubbe Exp $"); + RCSID("$Id: gc.c,v 1.47 2000/02/02 22:57:09 hubbe Exp $");      /* Run garbage collect approximate every time we have    * 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   #define MARKER_CHUNK_SIZE 1023      INT32 num_objects =0;   INT32 num_allocs =0;   INT32 alloc_threshold = MIN_ALLOC_THRESHOLD;   static int in_gc = 0;   struct pike_queue gc_mark_queue; -  + time_t last_gc;    -  +    static double objects_alloced = 0.0;   static double objects_freed = 0.0;      struct callback_list gc_callbacks;      struct callback *debug_add_gc_callback(callback_func call,    void *arg,    callback_func free_func)   {    return add_to_callback(&gc_callbacks, call, arg, free_func);
pike.git/src/gc.c:65:   #ifdef PIKE_DEBUG   #define INIT_BLOCK(X) (X)->flags=(X)->refs=(X)->xrefs=0   #else   #define INIT_BLOCK(X) (X)->flags=(X)->refs=0   #endif      PTR_HASH_ALLOC(marker,MARKER_CHUNK_SIZE)      #ifdef PIKE_DEBUG    - time_t last_gc; -  +    void dump_gc_info(void)   {    fprintf(stderr,"Current number of objects: %ld\n",(long)num_objects);    fprintf(stderr,"Objects allocated total : %ld\n",(long)num_allocs);    fprintf(stderr," threshold for next gc() : %ld\n",(long)alloc_threshold);    fprintf(stderr,"Average allocs per gc() : %f\n",objects_alloced);    fprintf(stderr,"Average frees per gc() : %f\n",objects_freed);    fprintf(stderr,"Second since last gc() : %ld\n", (long)TIME(0) - (long)last_gc);    fprintf(stderr,"Projected garbage : %f\n", objects_freed * (double) num_allocs / (double) alloc_threshold);    fprintf(stderr,"in_gc : %d\n", in_gc);
pike.git/src/gc.c:605:    }       tmp2=num_objects;      #ifdef PIKE_DEBUG    if(t_flag)    fprintf(stderr,"Garbage collecting ... ");    if(num_objects < 0)    fatal("Panic, less than zero objects!\n");    -  last_gc=TIME(0); +       #endif    -  +  last_gc=TIME(0); +     multiplier=pow(MULTIPLIER, (double) num_allocs / (double) alloc_threshold);    objects_alloced*=multiplier;    objects_alloced += (double) num_allocs;       objects_freed*=multiplier;    objects_freed += (double) num_objects;          init_gc();