malloc returning NULL, was Panic in OSMalloc??
malloc returning NULL, was Panic in OSMalloc??
- Subject: malloc returning NULL, was Panic in OSMalloc??
- From: Rick Macklem <email@hidden>
- Date: Fri, 11 Jan 2008 11:48:05 -0500 (EST)
I just responded to the "Panic in OSMalloc??" thread and then realized
that "what to do when malloc returns NULL" is an interesting question,
for which I don't have a good answer...
When malloc returns NULL, it makes sense that the system is in some sense
constipated. To know how much, you'd need to know how the allocators
are implemented and what they are being used for. (Beyond what I know
about MacOS X.)
It seems to me that a non-blocking malloc returning NULL could just
indicate that the allocator has hit a transient high water mark and
retrying the allocation allowing blocking would make sense?
Whether or not retrying a blocking malloc when it returns NULL is a good
plan is more questionable. It seems to me that, for this case, the system
may be pretty badly constipated and returning ENOMEM may be preferable?
My NFS code was written way back when, when the BSD kernel malloc never
failed for the blocking case, so I didn't have to deal with this.
I'm hoping others will have comments? rick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden