@@ -242,6 +242,13 @@ void* iallocate(VM * vm, size_t isize, int outerlock) {
242 vm->heap.size += size;
242 vm->heap.size += size;
244 idris_gc(vm);
244 idris_gc(vm);
246+ // If there's still not enough room, grow the heap and try again
247+ if (vm->heap.next + size >= vm->heap.end) {
248+ vm->heap.size += size+vm->heap.growth;
245#ifdef HAS_PTHREAD
252#ifdef HAS_PTHREAD
246 if (lock) { // not message passing
253 if (lock) { // not message passing
247 pthread_mutex_unlock(&vm->alloc_lock);
254 pthread_mutex_unlock(&vm->alloc_lock);