Skip to content

Commit

Permalink
Fix 'Unexpected heap growth' fail in gctest if GC_INITIAL_HEAP_SIZE i…
Browse files Browse the repository at this point in the history
…s set

* tests/gctest.c (initial_heapsize): New static variable.
* tests/gctest.c (check_heap_stats): Declare init_heap_sz local
variable; set max_heap_sz to initial_heapsize*1.01 if the former is
smaller.
* tests/gctest.c (enable_incremental_mode): Set initial_heapsize.
* tests/gctest.c [PCR] (test): Call enable_incremental_mode().
  • Loading branch information
ivmai committed Feb 12, 2024
1 parent 804fd77 commit 4c6d773
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/gctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1988,9 +1988,12 @@ static void test_long_mult(void)

#define NUMBER_ROUND_UP(v, bound) ((((v) + (bound) - 1) / (bound)) * (bound))

static size_t initial_heapsize;

static void check_heap_stats(void)
{
size_t max_heap_sz;
size_t init_heap_sz = initial_heapsize;
int i;
# ifndef GC_NO_FINALIZATION
# ifdef FINALIZE_ON_DEMAND
Expand Down Expand Up @@ -2036,6 +2039,9 @@ static void check_heap_stats(void)
# if defined(USE_MMAP) || defined(MSWIN32)
max_heap_sz = NUMBER_ROUND_UP(max_heap_sz, 4 * 1024 * 1024);
# endif
init_heap_sz += init_heap_sz / 100; /* add 1% for recycled blocks */
if (max_heap_sz < init_heap_sz)
max_heap_sz = init_heap_sz;

/* Garbage collect repeatedly so that all inaccessible objects */
/* can be finalized. */
Expand Down Expand Up @@ -2197,9 +2203,7 @@ void SetMinimumStack(long minSize)
MaxApplZone();
}
}

#define cMinStackSpace (512L * 1024L)

#endif

static void GC_CALLBACK warn_proc(char *msg, GC_word p)
Expand All @@ -2210,6 +2214,7 @@ static void GC_CALLBACK warn_proc(char *msg, GC_word p)

static void enable_incremental_mode(void)
{
initial_heapsize = GC_get_heap_size();
# ifndef NO_INCREMENTAL
unsigned vdbs = GC_get_supported_vdbs();

Expand Down Expand Up @@ -2574,7 +2579,7 @@ int test(void)
GC_noop1((GC_word)(GC_funcptr_uint)&test);
# endif
n_tests = 0;
/* GC_enable_incremental(); */
enable_incremental_mode();
GC_set_warn_proc(warn_proc);
set_print_procs();
th1 = PCR_Th_Fork(run_one_test, 0);
Expand Down

0 comments on commit 4c6d773

Please sign in to comment.