On Tue, 29 Nov 2011 18:03:01 +0200 Tom Hacohen
> On 29/11/11 15:44, Michael Blumenkrantz wrote:
> > Those wd checks are bs. If any of those ever failed your app would
> > go down in flames anyway.
> That's what I said in my first reply, everything will break if malloc
> fails, so I don't think we check for malloc success.
Well, there are three possibilities -
A) Everything goes down in flames.
2) Everything goes down gracefully.
III) Some things go down gracefully as the app / library switches to a
low memory mode. Perhaps it could free up some temporary or cached
memory it's not really needing right now, switch to an alternate lower
memory algorithm, or just tell the user "I'm sorry Dave, I can't do
Things might not be going down in flames if it's a big allocation that
failed, and you can still allocate lots of smaller stuff. So instead
of just using a bad alloc and at some point in the future having a
mysterious crash, it's better to tell the user "Um, you don't have
enough RAM to use that 5 TB highly detailed image of the surface of
Mars as a window icon, try something a bit smaller".
But yeah, if there is not enough RAM available to allocate the string
"Fuck you and your dog, not enough bytes to tell you to go to hell",
then crashing mysteriously might be a valid option. Or you could pre
allocate it, like we do for the White Box of Death.
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.