[ccan] help with gracefully dealing with alloc failure in a recursive function
Sam Watkins
sam at nipl.net
Wed Oct 12 09:23:45 EST 2011
> 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.
One way to protect against the system running out of memory is to impose a
'ulimit' or memory limit per user or per process. Then the XML process might
run out of (its share of) memory without breaking the whole system.
As for freeing the XML data structures, aren't they linked together?
Why not long-jump out of the parser however you'd like to, then call
free_whole_xml_tree() or whatever? Or it could just return 'the tree so far'
with an error code, and let the user free it or keep it.
I like the idea of doing alloc within a context, so you can free a whole lot of
things all together. I heard that apache uses this to free everything for a
request, after it's been handled.
Sam
More information about the ccan
mailing list