diff --git a/releasenotes.md b/releasenotes.md index f4d89707e..b98530672 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -26,6 +26,7 @@ - Deprecate old `void!` @benchmark and @test functions. - Allow test runners to take String[] arguments. - Added `--lsp` output. +- Improve the error message when running out of memory. ### Fixes - Fix case trying to initialize a `char[*]*` from a String. diff --git a/src/utils/vmem.c b/src/utils/vmem.c index 983fc7a93..b4d4fa3fd 100644 --- a/src/utils/vmem.c +++ b/src/utils/vmem.c @@ -71,7 +71,11 @@ static inline void* mmap_allocate(Vmem *vmem, size_t to_allocate) #endif void *ptr = ((uint8_t *)vmem->ptr) + vmem->allocated; vmem->allocated = allocated_after; - ASSERT0(vmem->size > vmem->allocated); + if (vmem->size < allocated_after) + { + error_exit("Error: The compiler ran out of memory! Over %u MB was allocated from a single memory arena, perhaps " + "you called some recursive macro?", (unsigned)(vmem->size / (1024 * 1204))); + } return ptr; }