There are two unforgivable users of malloc: programs that don’t check the return value, and libraries that kill the program if returns NULL.
-
-
Replying to @AnthonyJBentley @Sonophoto and
virtual memory be available?
2 replies 0 retweets 0 likes -
Replying to @ArvidGerstmann @AnthonyJBentley and
No. I assume by virt mem you actually mean swap, which is a horrible idea bc it just changes failure mode to bogging down swapping for weeks
2 replies 0 retweets 1 like -
Replying to @RichFelker @AnthonyJBentley and
Yes, I meant swap. malloc is returning NULL if swapped? I forgot about limited 32bit addr. space. That's a likely case.
1 reply 0 retweets 0 likes -
Replying to @ArvidGerstmann @AnthonyJBentley and
No, I just mean having (nontrivial amounts of) swap is a very bad idea. Instead of malloc failing & being able to report failure...
1 reply 0 retweets 0 likes -
Replying to @RichFelker @ArvidGerstmann and
...you can get the system into a state where it would take weeks to successfully login & kill whatever allocated so much.
2 replies 0 retweets 0 likes -
Replying to @RichFelker @AnthonyJBentley and
Yes, I've been in such situations. They aren't cool. What's suggested on Linux to do on malloc failure? In games it's easy, you often have a
2 replies 0 retweets 0 likes -
Replying to @ArvidGerstmann @AnthonyJBentley and
Library level - back out the operation and return an error (you did remember not to commit/free anything before finishing alloc, right?).
1 reply 0 retweets 1 like -
Replying to @RichFelker @ArvidGerstmann and
Application level - depends on the app. Those with no valuable data of any sort can just try to show an error and exit...
1 reply 0 retweets 0 likes -
Replying to @RichFelker @ArvidGerstmann and
But if you have any data the user might be upset to lose, you need at least an allocation-free emergency-save/recovery-dump code path.
1 reply 0 retweets 0 likes
Or you need to ensure that data is constantly saved in a form suitable for recovery after abort (see browsers' tab-restore features).
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.