Installing a handler for running out of memory in "new".

Bro will now print an error message in that case rather than abort
with an uncaught exception.
This commit is contained in:
Robin Sommer 2012-08-16 11:48:56 -07:00
parent 4c3be63919
commit 4da209d3b1
4 changed files with 18 additions and 2 deletions

View file

@ -1383,7 +1383,13 @@ void safe_close(int fd)
void out_of_memory(const char* where)
{
reporter->FatalError("out of memory in %s.\n", where);
fprintf(stderr, "out of memory in %s.\n", where);
if ( reporter )
// Guess that might fail here if memory is really tight ...
reporter->FatalError("out of memory in %s.\n", where);
abort();
}
void get_memory_usage(unsigned int* total, unsigned int* malloced)