diff options
author | Hans Boehm <Hans_Boehm@hp.com> | 2002-04-09 00:39:16 +0000 |
---|---|---|
committer | Hans Boehm <hboehm@gcc.gnu.org> | 2002-04-09 00:39:16 +0000 |
commit | 787bf7e377c15754ff9f0670dbeb037125faad7d (patch) | |
tree | 0f43ea46e4d334b0f5b6be281db4806e87434993 | |
parent | cc382e5c1af3b867867cde8f906ae9fbfc9ac105 (diff) | |
download | gcc-787bf7e377c15754ff9f0670dbeb037125faad7d.zip gcc-787bf7e377c15754ff9f0670dbeb037125faad7d.tar.gz gcc-787bf7e377c15754ff9f0670dbeb037125faad7d.tar.bz2 |
gc_priv.h (WARN macro): Add "GC warning:" prefix.
* include/private/gc_priv.h (WARN macro): Add "GC warning:" prefix.
(GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed):
declare.
* allchblk.c (GC_allchblk_nth): Change text and support reduced
frequency for blacklist warning message.
* misc.c (GC_large_alloc_warn_interval,
GC_large_alloc_warn_suppressed): define.
(GC_init_inner): Check GC_NO_BLACKLIST_WARNING and
GC_LARGE_ALLOC_WARN_INTERVAL environment variables.
* doc/README.environment (GC_NO_BLACKLIST_WARNING): Deprecate.
(GC_LARGE_ALLOC_WARN_INTERVAL): Add documentation.
* dyn_load.c (_DYNAMIC): Move declaration to file scope.
From-SVN: r52053
-rw-r--r-- | boehm-gc/ChangeLog | 16 | ||||
-rw-r--r-- | boehm-gc/allchblk.c | 10 | ||||
-rw-r--r-- | boehm-gc/doc/README.environment | 11 | ||||
-rw-r--r-- | boehm-gc/dyn_load.c | 9 | ||||
-rw-r--r-- | boehm-gc/include/private/gc_priv.h | 9 | ||||
-rw-r--r-- | boehm-gc/misc.c | 25 |
6 files changed, 68 insertions, 12 deletions
diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog index 4d2af97..157adaa 100644 --- a/boehm-gc/ChangeLog +++ b/boehm-gc/ChangeLog @@ -1,3 +1,19 @@ +2002-04-08 Hans Boehm <Hans_Boehm@hp.com> + + * include/private/gc_priv.h (WARN macro): Add "GC warning:" prefix. + (GC_large_alloc_warn_interval, GC_large_alloc_warn_suppressed): + declare. + * allchblk.c (GC_allchblk_nth): Change text and support reduced + frequency for blacklist warning message. + * misc.c (GC_large_alloc_warn_interval, + GC_large_alloc_warn_suppressed): define. + (GC_init_inner): Check GC_NO_BLACKLIST_WARNING and + GC_LARGE_ALLOC_WARN_INTERVAL environment variables. + * doc/README.environment (GC_NO_BLACKLIST_WARNING): Deprecate. + (GC_LARGE_ALLOC_WARN_INTERVAL): Add documentation. + + * dyn_load.c (_DYNAMIC): Move declaration to file scope. + 2002-04-04 Loren J. Rittle <ljrittle@acm.org> * include/private/gcconfig.h: Add support for an unmapped diff --git a/boehm-gc/allchblk.c b/boehm-gc/allchblk.c index 3da58c4..7d4cbd8 100644 --- a/boehm-gc/allchblk.c +++ b/boehm-gc/allchblk.c @@ -654,9 +654,13 @@ int n; && orig_avail - size_needed > (signed_word)BL_LIMIT) { /* Punt, since anything else risks unreasonable heap growth. */ - if (0 == GETENV("GC_NO_BLACKLIST_WARNING")) { - WARN("Needed to allocate blacklisted block at 0x%lx\n", - (word)hbp); + if (++GC_large_alloc_warn_suppressed + >= GC_large_alloc_warn_interval) { + WARN("Repeated allocation of very large block " + "(appr. size %ld):\n" + "\tMay lead to memory leak and poor performance.\n", + size_needed); + GC_large_alloc_warn_suppressed = 0; } size_avail = orig_avail; } else if (size_avail == 0 && size_needed == HBLKSIZE diff --git a/boehm-gc/doc/README.environment b/boehm-gc/doc/README.environment index 6b25af1..c7daddb 100644 --- a/boehm-gc/doc/README.environment +++ b/boehm-gc/doc/README.environment @@ -30,7 +30,16 @@ GC_NPROCS=<n> - Linux w/threads only. Explicitly sets the number of processors correctness, but may lead to really horrible performance. GC_NO_BLACKLIST_WARNING - Prevents the collector from issuing - "Needed to allocate blacklisted block at ..." warnings. + warnings about allocations of very large blocks. + Deprecated. Use GC_LARGE_ALLOC_WARN_INTERVAL instead. + +GC_LARGE_ALLOC_WARN_INTERVAL=<n> - Print every nth warning about very large + block allocations, starting with the nth one. Small values + of n are generally benign, in that a bounded number of + such warnings generally indicate at most a bounded leak. + For best results it should be set at 1 during testing. + Default is 5. Very large numbers effectively disable the + warning. GC_IGNORE_GCJ_INFO - Ignore the type descriptors implicitly supplied by GC_gcj_malloc and friends. This is useful for debugging diff --git a/boehm-gc/dyn_load.c b/boehm-gc/dyn_load.c index a267637..d3ef572 100644 --- a/boehm-gc/dyn_load.c +++ b/boehm-gc/dyn_load.c @@ -529,13 +529,14 @@ GC_bool GC_register_dynamic_libraries_dl_iterate_phdr() # endif +#ifdef __GNUC__ +# pragma weak _DYNAMIC +#endif +extern ElfW(Dyn) _DYNAMIC[]; + static struct link_map * GC_FirstDLOpenedLinkMap() { -# ifdef __GNUC__ -# pragma weak _DYNAMIC -# endif - extern ElfW(Dyn) _DYNAMIC[]; ElfW(Dyn) *dp; struct r_debug *r; static struct link_map *cachedResult = 0; diff --git a/boehm-gc/include/private/gc_priv.h b/boehm-gc/include/private/gc_priv.h index 642cad8..b1526aa 100644 --- a/boehm-gc/include/private/gc_priv.h +++ b/boehm-gc/include/private/gc_priv.h @@ -499,7 +499,7 @@ struct hblk; /* See below. */ # endif /* Print warning message, e.g. almost out of memory. */ -# define WARN(msg,arg) (*GC_current_warn_proc)(msg, (GC_word)(arg)) +# define WARN(msg,arg) (*GC_current_warn_proc)("GC Warning: " msg, (GC_word)(arg)) extern GC_warn_proc GC_current_warn_proc; /* Get environment entry */ @@ -1223,7 +1223,12 @@ extern word GC_root_size; /* Total size of registered root sections */ extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ - +extern long GC_large_alloc_warn_interval; + /* Interval between unsuppressed warnings. */ + +extern long GC_large_alloc_warn_suppressed; + /* Number of warnings suppressed so far. */ + /* Operations */ # ifndef abs # define abs(x) ((x) < 0? (-(x)) : (x)) diff --git a/boehm-gc/misc.c b/boehm-gc/misc.c index 50955f4..f607973 100644 --- a/boehm-gc/misc.c +++ b/boehm-gc/misc.c @@ -16,6 +16,7 @@ #include <stdio.h> +#include <limits.h> #ifndef _WIN32_WCE #include <signal.h> #endif @@ -112,6 +113,12 @@ GC_bool GC_print_back_height = 0; int GC_all_interior_pointers = 0; #endif +long GC_large_alloc_warn_interval = 5; + /* Interval between unsuppressed warnings. */ + +long GC_large_alloc_warn_suppressed = 0; + /* Number of warnings suppressed so far. */ + /*ARGSUSED*/ GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested)) { @@ -518,11 +525,13 @@ void GC_init_inner() if (0 != GETENV("GC_PRINT_BACK_HEIGHT")) { GC_print_back_height = 1; } + if (0 != GETENV("GC_NO_BLACKLIST_WARNING")) { + GC_large_alloc_warn_interval = LONG_MAX; + } { char * time_limit_string = GETENV("GC_PAUSE_TIME_TARGET"); if (0 != time_limit_string) { - long time_limit; - if (time_limit_string != 0) time_limit = atol(time_limit_string); + long time_limit = atol(time_limit_string); if (time_limit < 5) { WARN("GC_PAUSE_TIME_TARGET environment variable value too small " "or bad syntax: Ignoring\n", 0); @@ -531,6 +540,18 @@ void GC_init_inner() } } } + { + char * interval_string = GETENV("GC_LARGE_ALLOC_WARN_INTERVAL"); + if (0 != interval_string) { + long interval = atol(interval_string); + if (interval <= 0) { + WARN("GC_LARGE_ALLOC_WARN_INTERVAL environment variable has " + "bad value: Ignoring\n", 0); + } else { + GC_large_alloc_warn_interval = interval; + } + } + } # ifdef UNIX_LIKE if (0 != GETENV("GC_LOOP_ON_ABORT")) { GC_set_and_save_fault_handler(looping_handler); |