3 ms·
I knew that people would nit-pick on this and not address the actual issue. Next time, I should try harder to come up with a better example. My point is: somet
by alextingle 13y ago
I knew that people would nit-pick on this and not address the actual issue. Next time, I should try harder to come up with a better example.
My point is: sometimes it is worth trying to recover when malloc() fails.
- sitkack 13y agoI wasn't trying to nitpick. Correcting the example, and yes recovering from a malloc failure _could_ be a worthy goal, but on Linux by the time your app is getting signaled about malloc failures the OOM killer is already playing little bunny foo foo with ur processes. If your app can operate under different allocation regimes then there should be side channels for dynamically adjusting the memory usage at runtime. On Linux, failed malloc is not that signal and since _so many_ libraries and language runtime semantics allocate memory, making sure you allocate no memory in your bad-malloc path is very difficult.