[ccan] help with gracefully dealing with alloc failure in a recursive function

David Gibson david at gibson.dropbear.id.au
Mon Oct 10 21:28:36 EST 2011


On Mon, Oct 10, 2011 at 02:26:51AM -0400, Joey Adams wrote:
> On Thu, Oct 6, 2011 at 9:12 PM, Michael Cohen <scudette at gmail.com> wrote:
> > So a couple of points:
> >
> > -  If you fail to allocate memory what can you do now? Does it even
> > make sense to handle this error? Its unlikely that you can recover the
> > system to a sufficiently coherent state to be useful. Usually when I
> > run out of memory I prefer to segfault rather than try to recover.
> > ...
> 
> Running out of memory does not mean the application cannot return to a
> sane state.  Maybe the user was trying to load a 500MB file.  In this
> case, the error handling code will free a lot of memory.

In theory, yes.  In practice, no-one will bother since running out of
memory is vanishingly rare on a modern VM system, except in situations
where you have bigger problems than your XML app dying.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson


More information about the ccan mailing list