~ chicken-core (chicken-5) 2ff95afa0c34b98c6c063e46568f5275f64b4116
commit 2ff95afa0c34b98c6c063e46568f5275f64b4116 Author: Peter Bex <peter.bex@xs4all.nl> AuthorDate: Sat Jun 30 12:46:33 2012 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Mon Jul 2 10:54:52 2012 +0200 When resizing the heap ensure it grows enough to accommodate the nursery. This fixes out of memory errors in extreme cases like allocating finalizers on lots of objects in a tight loop Signed-off-by: felix <felix@call-with-current-continuation.org> diff --git a/runtime.c b/runtime.c index b0ccc85a..04d476fa 100644 --- a/runtime.c +++ b/runtime.c @@ -139,8 +139,8 @@ extern void _C_do_apply_hack(void *proc, C_word *args, int count) C_noret; #endif #define DEFAULT_SYMBOL_TABLE_SIZE 2999 -#define DEFAULT_HEAP_SIZE 500000 -#define MINIMAL_HEAP_SIZE 500000 +#define DEFAULT_HEAP_SIZE DEFAULT_STACK_SIZE +#define MINIMAL_HEAP_SIZE DEFAULT_STACK_SIZE #define DEFAULT_MAXIMAL_HEAP_SIZE 0x7ffffff0 #define DEFAULT_HEAP_GROWTH 200 #define DEFAULT_HEAP_SHRINKAGE 50 @@ -3120,6 +3120,9 @@ C_regparm void C_fcall C_rereclaim2(C_uword size, int double_plus) if(size < MINIMAL_HEAP_SIZE) size = MINIMAL_HEAP_SIZE; + /* Heap must at least grow enough to accommodate first generation (nursery) */ + if(size - heap_size < stack_size) size = heap_size + stack_size; + if(size > C_maximal_heap_size) size = C_maximal_heap_size; if(size == heap_size) return; diff --git a/tests/runtests.bat b/tests/runtests.bat index 93efb4d3..753257ac 100644 --- a/tests/runtests.bat +++ b/tests/runtests.bat @@ -400,6 +400,10 @@ echo ======================================== finalizer tests ... if errorlevel 1 exit /b 1 echo ======================================== finalizer tests (2) ... +%compile% finalizer-error-test.scm +if errorlevel 1 exit /b 1 +a.out -:hg101 +if errorlevel 1 exit /b 1 %compile% test-finalizers-2.scm if errorlevel 1 exit /b 1 a.out diff --git a/tests/runtests.sh b/tests/runtests.sh index a87d750b..093115c5 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -348,7 +348,7 @@ $compile symbolgc-tests.scm echo "======================================== finalizer tests ..." $interpret -s test-finalizers.scm $compile finalizer-error-test.scm -./a.out +./a.out -:hg101 $compile test-finalizers-2.scm ./a.outTrap