diff --git a/runtime/gc.c b/runtime/gc.c index b8d5d0540..5f5c937b7 100644 --- a/runtime/gc.c +++ b/runtime/gc.c @@ -277,9 +277,10 @@ void compact_phase (size_t additional_size) { size_t next_heap_pseudo_size = MAX(next_heap_size, heap.size); memory_chunk old_heap = heap; - heap.begin = mremap(heap.begin, WORDS_TO_BYTES(heap.size), WORDS_TO_BYTES(next_heap_pseudo_size), MREMAP_MAYMOVE); + heap.begin = mmap(NULL, WORDS_TO_BYTES(next_heap_pseudo_size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + memcpy(heap.begin, old_heap.begin, WORDS_TO_BYTES(old_heap.size)); if (heap.begin == MAP_FAILED) { - perror("ERROR: compact_phase: mremap failed\n"); + perror("ERROR: compact_phase: mmap failed\n"); exit(1); } heap.end = heap.begin + next_heap_pseudo_size; @@ -290,6 +291,10 @@ void compact_phase (size_t additional_size) { physically_relocate(&old_heap); heap.current = heap.begin + live_size; +// if (munmap(old_heap.begin, old_heap.size) < 0) { +// perror("ERROR: compact_phase: munmap failed\n"); +// exit(1); +// } } size_t compute_locations () {