2 ms·
When the global allocator fails, you might not be able to do much... except set a flag, and free a big block of memory that was reserved against just such an ev
by ncmncm 7y ago
When the global allocator fails, you might not be able to do much... except set a flag, and free a big block of memory that was reserved against just such an event.
Then the program can do whatever cleanup is warranted, maybe freeing up a variety of other resources, and then maybe re-reserve that block, and forge ahead.
But when you actually care about performance, you often are not using the global allocator. A local allocation failure is nothing to panic over. Generally, only the higher level code -- where the handler is -- knows, or needs to care, what kind of allocator failed. The low-level code gets to just bail out, as it should.