diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2020-07-31 21:39:47 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2020-07-31 22:03:50 +0300 |
commit | 2bff37a90ff13c256f6ffd59a69b60b45ab7cab0 (patch) | |
tree | 3076c1012701224b2daebd68df8ae24edaf27571 /tests | |
parent | 802e47d5e8dcbddd2e80cd4587eacc5f4ffbc745 (diff) | |
download | bdwgc-2bff37a90ff13c256f6ffd59a69b60b45ab7cab0.tar.gz |
Do not hard-code finalizable objects limit which triggers GC
Issue #304 (bdwgc).
Previously, if more than 500 finalizable objects emerged since the
latest collection (and the incremental mode is off), then new
collection is started instead heap expansion. This led to frequent
collections if most allocated objects were with a registered finalizer.
Now, the hard coded limit (500) is replaced roughly with
(GC_bytes_allocd / GC_allocd_bytes_per_finalizer), where the latter
global variable has the default value of 10000 (or
GC_ALLOCD_BYTES_PER_FINALIZER if defined) but could be changed by the
client with GC_set_allocd_bytes_per_finalizer().
* alloc.c (GC_allocd_bytes_per_finalizer): New STATIC variable
(initialized to GC_ALLOCD_BYTES_PER_FINALIZER if defined otherwise to 10000).
* alloc.c (GC_set_allocd_bytes_per_finalizer,
GC_get_allocd_bytes_per_finalizer): New API function definition.
* alloc.c (GC_collect_or_expand): Replace
GC_fo_entries>last_fo_entries+500 condition to
GC_fo_entries>last_fo_entries &&
(GC_fo_entries-last_fo_entries)*GC_allocd_bytes_per_finalizer
>GC_bytes_allocd.
* doc/README.macros (GC_ALLOCD_BYTES_PER_FINALIZER): Document.
* include/gc.h (GC_set_allocd_bytes_per_finalizer,
GC_get_allocd_bytes_per_finalizer): New API function declaration.
* include/gc.h (GC_INIT_CONF_ALLOCD_BYTES_PER_FINALIZER): New internal
macro (call GC_set_allocd_bytes_per_finalizer if
GC_ALLOCD_BYTES_PER_FINALIZER is defined by client).
* include/gc.h (GC_INIT): Call GC_INIT_CONF_ALLOCD_BYTES_PER_FINALIZER.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK]
(main): Call UNTESTED() for GC_get_allocd_bytes_per_finalizer and
GC_set_allocd_bytes_per_finalizer.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/test.c b/tests/test.c index e2ebc259..f3623d15 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1993,6 +1993,7 @@ void GC_CALLBACK warn_proc(char *msg, GC_word p) UNTESTED(GetSymbolNameFromStack); # endif UNTESTED(GC_abort_on_oom); + UNTESTED(GC_get_allocd_bytes_per_finalizer); UNTESTED(GC_get_bytes_since_gc); UNTESTED(GC_get_dont_expand); UNTESTED(GC_get_dont_precollect); @@ -2015,6 +2016,7 @@ void GC_CALLBACK warn_proc(char *msg, GC_word p) UNTESTED(GC_get_time_limit); UNTESTED(GC_get_warn_proc); UNTESTED(GC_is_disabled); + UNTESTED(GC_set_allocd_bytes_per_finalizer); UNTESTED(GC_set_dont_precollect); UNTESTED(GC_set_finalize_on_demand); UNTESTED(GC_set_finalizer_notifier); |