Re: Allocating too much memory kills my App rather than returning NULL
Re: Allocating too much memory kills my App rather than returning NULL
- Subject: Re: Allocating too much memory kills my App rather than returning NULL
- From: Bill Bumgarner <email@hidden>
- Date: Fri, 11 Nov 2011 09:22:40 -0800
On Nov 10, 2011, at 6:03 PM, Don Quixote de la Mancha wrote:
> I don't have a problem with the system killing runaway processes.
> What I have a problem with is that calloc() NEVER returns NULL. If it
> ever did, I would have plenty of opportunity to deallocate ALL of the
> memory I just allocated, and stop attempting to allocate any more.
The only situation where this would ever work is if the process were single threaded. As well, every single call to an allocator everywhere in the entire system would have to check for NULL and provide a recovery codepath. Not only would this be rife with bugs, it would also explode the size of the code.
Multiple threads are effectively a red herring in this; threads just mean that all that failsafe code also has to deal with failing safely in a multi-thread environment.
And for what purpose?
In a 64 bit world with a VM, your system will be completely unusable long, long, long before the first failed allocation because you'll be paging like mad (unless whatever volume that holds VM is already full).
b.bum
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden