* 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
+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
&& 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
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
# 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;
# 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 */
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))
#include <stdio.h>
+#include <limits.h>
#ifndef _WIN32_WCE
#include <signal.h>
#endif
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))
{
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);
}
}
}
+ {
+ 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);