Improve the error message when running out of memory.

This commit is contained in:
Christoffer Lerno
2025-01-10 00:29:08 +01:00
parent d67fcb3956
commit 0d1fb2843e
2 changed files with 6 additions and 1 deletions

View File

@@ -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.

View File

@@ -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;
}