diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-02-23 18:33:45 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-02-23 18:33:45 +0300 |
commit | b82d4a16b60c38584cf238cbaf7f98549865d8cb (patch) | |
tree | 04e575c5fa558c85fcdb1dcf39850da79e3616ce /alloc.c | |
parent | d93875239734b39fc840c468fbb620551186468c (diff) | |
download | bdwgc-b82d4a16b60c38584cf238cbaf7f98549865d8cb.tar.gz |
Warn if heap has grown while GC was disabled
* alloc.c (GC_expand_hp): Increment GC_heapsize_on_gc_disable by the
corresponding size if GC disabled and the heap is expanded.
* include/private/gc_priv.h (GC_arrays._heapsize_on_gc_disable):
Declare field.
* misc.c (GC_enable): Call WARN with the appropriate message if going
from GC disabled to enabled mode and the heap size is greater than
GC_heapsize_on_gc_disable.
* misc.c (GC_disable): Store the current heap size value to
GC_heapsize_on_gc_disable if going from GC enabled to disabled mode.
Diffstat (limited to 'alloc.c')
-rw-r--r-- | alloc.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1608,7 +1608,13 @@ GC_API int GC_CALL GC_expand_hp(size_t bytes) if (!EXPECT(GC_is_initialized, TRUE)) GC_init(); LOCK(); result = GC_expand_hp_inner(n_blocks); - if (result) GC_requested_heapsize += bytes; + if (result) { + GC_requested_heapsize += bytes; + if (GC_dont_gc) { + /* Do not call WARN if the heap growth is intentional. */ + GC_heapsize_on_gc_disable += n_blocks * HBLKSIZE; + } + } UNLOCK(); return (int)result; } |