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: Don Quixote de la Mancha <email@hidden>
- Date: Thu, 10 Nov 2011 18:03:42 -0800
On Thu, Nov 10, 2011 at 9:52 AM, Kyle Sluder <email@hidden> wrote:
> Read carefully: “If you allocate memory faster than the OS can re-claim it from other processes…” In other words, the system protects against apps that might've gotten trapped in an infinite loop of allocating memory. Better to kill the errant app without sacrificing other apps to its unsatisfiable demands.
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.
Instead of ever receiving an allocation failure, my process is just killed.
My process isn't killed by a UNIX signal. If it were I could use a
signal handler to free up all that memory.
calloc() and malloc() are documented to return NULL when there isn't
enough memory to satisfy the user's request. Their implementation is
simply broken if they don't do that.
--
Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
http://www.dulcineatech.com
email@hidden
_______________________________________________
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