Commit 787bf7e3 by Hans Boehm Committed by Hans Boehm

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
parent cc382e5c
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> 2002-04-04 Loren J. Rittle <ljrittle@acm.org>
* include/private/gcconfig.h: Add support for an unmapped * include/private/gcconfig.h: Add support for an unmapped
......
...@@ -654,9 +654,13 @@ int n; ...@@ -654,9 +654,13 @@ int n;
&& orig_avail - size_needed && orig_avail - size_needed
> (signed_word)BL_LIMIT) { > (signed_word)BL_LIMIT) {
/* Punt, since anything else risks unreasonable heap growth. */ /* Punt, since anything else risks unreasonable heap growth. */
if (0 == GETENV("GC_NO_BLACKLIST_WARNING")) { if (++GC_large_alloc_warn_suppressed
WARN("Needed to allocate blacklisted block at 0x%lx\n", >= GC_large_alloc_warn_interval) {
(word)hbp); 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; size_avail = orig_avail;
} else if (size_avail == 0 && size_needed == HBLKSIZE } else if (size_avail == 0 && size_needed == HBLKSIZE
......
...@@ -30,7 +30,16 @@ GC_NPROCS=<n> - Linux w/threads only. Explicitly sets the number of processors ...@@ -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. correctness, but may lead to really horrible performance.
GC_NO_BLACKLIST_WARNING - Prevents the collector from issuing 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_IGNORE_GCJ_INFO - Ignore the type descriptors implicitly supplied by
GC_gcj_malloc and friends. This is useful for debugging GC_gcj_malloc and friends. This is useful for debugging
......
...@@ -529,13 +529,14 @@ GC_bool GC_register_dynamic_libraries_dl_iterate_phdr() ...@@ -529,13 +529,14 @@ GC_bool GC_register_dynamic_libraries_dl_iterate_phdr()
# endif # endif
#ifdef __GNUC__
# pragma weak _DYNAMIC
#endif
extern ElfW(Dyn) _DYNAMIC[];
static struct link_map * static struct link_map *
GC_FirstDLOpenedLinkMap() GC_FirstDLOpenedLinkMap()
{ {
# ifdef __GNUC__
# pragma weak _DYNAMIC
# endif
extern ElfW(Dyn) _DYNAMIC[];
ElfW(Dyn) *dp; ElfW(Dyn) *dp;
struct r_debug *r; struct r_debug *r;
static struct link_map *cachedResult = 0; static struct link_map *cachedResult = 0;
......
...@@ -499,7 +499,7 @@ struct hblk; /* See below. */ ...@@ -499,7 +499,7 @@ struct hblk; /* See below. */
# endif # endif
/* Print warning message, e.g. almost out of memory. */ /* 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; extern GC_warn_proc GC_current_warn_proc;
/* Get environment entry */ /* Get environment entry */
...@@ -1223,6 +1223,11 @@ extern word GC_root_size; /* Total size of registered root sections */ ...@@ -1223,6 +1223,11 @@ extern word GC_root_size; /* Total size of registered root sections */
extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */ 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 */ /* Operations */
# ifndef abs # ifndef abs
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <stdio.h> #include <stdio.h>
#include <limits.h>
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
#include <signal.h> #include <signal.h>
#endif #endif
...@@ -112,6 +113,12 @@ GC_bool GC_print_back_height = 0; ...@@ -112,6 +113,12 @@ GC_bool GC_print_back_height = 0;
int GC_all_interior_pointers = 0; int GC_all_interior_pointers = 0;
#endif #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*/ /*ARGSUSED*/
GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested)) GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested))
{ {
...@@ -518,11 +525,13 @@ void GC_init_inner() ...@@ -518,11 +525,13 @@ void GC_init_inner()
if (0 != GETENV("GC_PRINT_BACK_HEIGHT")) { if (0 != GETENV("GC_PRINT_BACK_HEIGHT")) {
GC_print_back_height = 1; 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"); char * time_limit_string = GETENV("GC_PAUSE_TIME_TARGET");
if (0 != time_limit_string) { if (0 != time_limit_string) {
long time_limit; long time_limit = atol(time_limit_string);
if (time_limit_string != 0) time_limit = atol(time_limit_string);
if (time_limit < 5) { if (time_limit < 5) {
WARN("GC_PAUSE_TIME_TARGET environment variable value too small " WARN("GC_PAUSE_TIME_TARGET environment variable value too small "
"or bad syntax: Ignoring\n", 0); "or bad syntax: Ignoring\n", 0);
...@@ -531,6 +540,18 @@ void GC_init_inner() ...@@ -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 # ifdef UNIX_LIKE
if (0 != GETENV("GC_LOOP_ON_ABORT")) { if (0 != GETENV("GC_LOOP_ON_ABORT")) {
GC_set_and_save_fault_handler(looping_handler); GC_set_and_save_fault_handler(looping_handler);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment