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.253 2004/04/18 02:16:05 mast Exp $ + || $Id: gc.c,v 1.254 2004/05/23 00:44:34 nilsson 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:26:   #include "interpret.h"   #include "bignum.h"   #include "pike_threadlib.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $"); + RCSID("$Id: gc.c,v 1.254 2004/05/23 00:44:34 nilsson Exp $");      int gc_enabled = 1;      /* These defaults are only guesses and hardly tested at all. Please improve. */   double gc_garbage_ratio_low = 0.2;   double gc_time_ratio = 0.05;   double gc_garbage_ratio_high = 0.5;      /* This slowness factor approximately corresponds to the average over    * the last ten gc rounds. (0.9 == 1 - 1/10) */
pike.git/src/gc.c:250:   #endif      PTR_HASH_ALLOC_FIXED_FILL_PAGES(marker,2)      #if defined (PIKE_DEBUG) || defined (GC_MARK_DEBUG)   void *gc_found_in = NULL;   int gc_found_in_type = PIKE_T_UNKNOWN;   const char *gc_found_place = NULL;   #endif    + #ifdef DO_PIKE_CLEANUP + /* To keep the markers after the gc. Only used for the leak report at exit. */ + int gc_keep_markers = 0; + int gc_external_refs_zapped = 0; + #endif +    #ifdef PIKE_DEBUG      #undef get_marker   #define get_marker(X) ((struct marker *) debug_malloc_pass(debug_get_marker(X)))   #undef find_marker   #define find_marker(X) ((struct marker *) debug_malloc_pass(debug_find_marker(X)))      int gc_in_cycle_check = 0;   static unsigned delayed_freed, weak_freed, checked, marked, cycle_checked, live_ref;   static unsigned max_gc_frames, num_gc_frames = 0, live_rec, frame_rot;
pike.git/src/gc.c:333:       return PIKE_T_UNKNOWN;   }      void *check_for =0;   void *gc_svalue_location=0;   static size_t found_ref_count;      char *fatal_after_gc=0;    - #ifdef DO_PIKE_CLEANUP - /* To keep the markers after the gc. Only used for the leak report at exit. */ - int gc_keep_markers = 0; - int gc_external_refs_zapped = 0; - #endif -  +    #define DESCRIBE_MEM 1   #define DESCRIBE_SHORT 4   #define DESCRIBE_NO_DMALLOC 8      /* type == -1 means that memblock is a char* and should be    * really be printed..    */   void describe_location(void *real_memblock,    int type,    void *location,
pike.git/src/gc.c:1585: Inside #if defined(PIKE_DEBUG)
     #ifdef PIKE_DEBUG    if (gc_is_watching) {    fprintf(stderr, "## Exiting gc and resetting watches for %d things.\n",    gc_is_watching);    gc_is_watching = 0;    }   #endif   }    + #ifdef DO_PIKE_CLEANUP + void gc_check_zapped (void *a, TYPE_T type, const char *file, int line) + { +  struct marker *m = find_marker (a); +  if (m && (m->flags & GC_CLEANUP_FREED)) +  fprintf (stderr, "Free of leaked %s %p from %s:%d, %d refs remaining\n", +  get_name_of_type (type), a, file, line, *(INT32 *)a - 1); + } + #endif +    #ifdef PIKE_DEBUG   /* This function marks some known externals. The rest are handled by    * callbacks added with add_gc_callback. */   static void mark_externals (void)   {    struct mapping *constants;    if (master_object)    gc_mark_external (master_object, " as master_object");    if ((constants = get_builtin_constants()))    gc_mark_external (constants, " as global constants mapping");
pike.git/src/gc.c:1772: Inside #if defined(PIKE_DEBUG)
   m=get_marker(a);    m->xrefs++;    m->flags|=GC_XREFERENCED;    if(Pike_in_gc == GC_PASS_CHECK &&    (m->refs + m->xrefs > *(INT32 *)a ||    (m->saved_refs != -1 && m->saved_refs != *(INT32 *)a)))    gc_fatal(a, 1, "Ref counts are wrong.\n");    return 0;   }    - #ifdef DO_PIKE_CLEANUP - void gc_check_zapped (void *a, TYPE_T type, const char *file, int line) - { -  struct marker *m = find_marker (a); -  if (m && (m->flags & GC_CLEANUP_FREED)) -  fprintf (stderr, "Free of leaked %s %p from %s:%d, %d refs remaining\n", -  get_name_of_type (type), a, file, line, *(INT32 *)a - 1); - } - #endif -  +    void debug_really_free_gc_frame(struct gc_frame *l)   {    if (l->frameflags & GC_LINK_FREED)    gc_fatal(l->data, 0, "Freeing freed gc_frame.\n");    l->frameflags |= GC_LINK_FREED;    l->back = PREV(l) = NEXT(l) = (struct gc_frame *)(ptrdiff_t) -1;    really_free_gc_frame(l);   #ifdef GC_VERBOSE    num_gc_frames--;   #endif