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: Joar Wingfors <email@hidden>
- Date: Tue, 08 Nov 2011 09:45:04 -0800
On 8 nov 2011, at 09:14, Wade Tregaskis wrote:
>>> Before I started writing iOS code I did embedded systems development
>>> and Mac OS X device drivers. In both of those environments, Failure
>>> Is Not An Option. While you can certainly run out of memory or
>>> encounter other errors, one just has to back out gracefully.
>>
>> This turns out not to be practical in a complex layered application environment. How do you even begin to write recovery code when any method dispatch could fail? How do you test it?
>
> This is a straw man. The existence of tricky edge cases does not justify careless code (nor imply that objc_msgSend is careless).
>
> For background, to anyone still following this thread at this point, I worked for several years in Apple's performance tools team(s). The vast majority of "performance" problems seen in bug reports, developer kitchens, WWDC labs, dev forums and mailing lists revolve around memory. A substantial fraction of those are specifically allocation failures - whether due to bogus arguments to malloc et al, or memory exhaustion on iOS, etc. The vast majority of those come to people's attention through crashes in their apps, often after shipping. Most of those crashes could be averted by simple error checking and graceful failure. Simple as that.
Simple as that, eh? Being able to gracefully handle all out of memory situations to me seems as "simple" as being required to treat every single method / function call as potentially raising an exception, and requiring the developer to add handlers + cleanup code. No existing code (OS or apps) is exceptions safe at every single line of source code. At the very least this would require a complete rewrite / review of every single line of existing source code in both OS and apps, something that seems neither simple nor practical to me.
j o a r
_______________________________________________
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