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.59 2000/04/13 23:52:29 hubbe Exp $"); + RCSID("$Id: gc.c,v 1.60 2000/04/14 15:23:45 mast 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; + int Pike_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,
pike.git/src/gc.c:76: Inside #if defined(PIKE_DEBUG)
     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); +  fprintf(stderr,"in_gc : %d\n", Pike_in_gc);   }      TYPE_T attempt_to_identify(void *something)   {    struct array *a;    struct object *o;    struct program *p;    struct mapping *m;    struct multiset *mu;   
pike.git/src/gc.c:608: Inside #if defined(DO_PIKE_CLEANUP)
   while(marker_hash_table[e])    remove_marker(marker_hash_table[e]->data);   #endif    exit_marker_hash();   #endif   }      #ifdef PIKE_DEBUG   void locate_references(void *a)   { -  if(!in_gc) +  if(!Pike_in_gc)    init_gc();       fprintf(stderr,"**Looking for references:\n");       check_for=a;       found_where=" in an array";    gc_check_all_arrays();       found_where=" in a multiset";
pike.git/src/gc.c:656: Inside #if defined(PIKE_DEBUG) and #if defined(DEBUG_MALLOC)
   {    extern void dmalloc_find_references_to(void *);   #if 0    fprintf(stderr,"**DMALLOC Looking for references:\n");    dmalloc_find_references_to(a);   #endif    }   #endif       -  if(!in_gc) +  if(!Pike_in_gc)    exit_gc();   }   #endif      #ifdef PIKE_DEBUG      int debug_gc_is_referenced(void *a)   {    struct marker *m;    m=get_marker(a);
pike.git/src/gc.c:719: Inside #if defined(PIKE_DEBUG)
      return 1;    }       if(check_for == (void *)1 && gc_do_free(a))    {    struct marker *m=get_marker(a);    int t=attempt_to_identify(a);    if(t != T_STRING && t != T_UNKNOWN)    { -  fprintf(stderr,"EXTERNAL Reference to object to free%s!\n",in?in:""); +  fprintf(stderr,"EXTERNAL Reference to object to free%s!\n",in?(char *)in:"");    fprintf(stderr," has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)m->refs,(long)m->xrefs);    if(where) describe_location(0,T_UNKNOWN,where);    describe(a);    locate_references(a);    fprintf(stderr,"##### Continuing search for more bugs....\n");    fatal_after_gc="EXTERNAL Reference to object to free.\n";    }    }       return 0;
pike.git/src/gc.c:792: Inside #if defined(PIKE_DEBUG)
      return !(m->flags & GC_REFERENCED);   }   #endif      void do_gc(void)   {    double tmp;    INT32 tmp2;    double multiplier; +  hrtime_t gcstarttime;    -  if(in_gc) return; -  in_gc=1; +  if(Pike_in_gc) return; +  Pike_in_gc=1;       if(gc_evaluator_callback)    {    remove_callback(gc_evaluator_callback);    gc_evaluator_callback=0;    }       tmp2=num_objects;      #ifdef PIKE_DEBUG -  if(t_flag) +  if(t_flag) {    fprintf(stderr,"Garbage collecting ... "); -  +  gcstarttime = gethrtime(); +  }    if(num_objects < 0)    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;   
pike.git/src/gc.c:866:         #ifdef PIKE_DEBUG    check_for=(void *)1;   #endif    /* Now we free the unused stuff */    gc_free_all_unreferenced_arrays();    gc_free_all_unreferenced_multisets();    gc_free_all_unreferenced_mappings();    gc_free_all_unreferenced_programs(); +  Pike_in_gc=2;    gc_free_all_unreferenced_objects();      #ifdef PIKE_DEBUG       check_for=0;    if(fatal_after_gc) fatal(fatal_after_gc);   #endif       exit_gc();   
pike.git/src/gc.c:898:    }       if(alloc_threshold < MIN_ALLOC_THRESHOLD)    alloc_threshold = MIN_ALLOC_THRESHOLD;    if(alloc_threshold > MAX_ALLOC_THRESHOLD)    alloc_threshold = MAX_ALLOC_THRESHOLD;    num_allocs=0;      #ifdef PIKE_DEBUG    if(t_flag) -  fprintf(stderr,"done (freed %ld of %ld objects).\n", -  (long)(tmp2-num_objects),(long)tmp2); +  fprintf(stderr,"done (freed %ld of %ld objects), %ld ms.\n", +  (long)(tmp2-num_objects),(long)tmp2, +  (long)((gethrtime() - gcstarttime)/1000000));   #endif      #ifdef ALWAYS_GC    ADD_GC_CALLBACK();   #else    if(d_flag > 3) ADD_GC_CALLBACK();   #endif -  in_gc=0; +  Pike_in_gc=0;   }         void f__gc_status(INT32 args)   {    pop_n_elems(args);       push_constant_text("num_objects");    push_int(num_objects);