04-27-07 06:17 AM
In article <1177564273.444549.48870@c18g2000prb.googlegroups.com>,
Bin Chen <binary.chen@gmail.com> wrote:
> On Apr 23, 9:29 pm, Rainer Temme <Rainer_Te...@nospam.hotmail_dot_com>
> wrote:
>
> But POSIX doesn't say anything about the malloc() is a blocking call,
> is it portable to rely malloc() but not try malloc again immediately?
You could try again, but it's not likely to improve. Most of the time
the reason for malloc failure is that the contiguous space isn't
available in your process's heap. It's possible that it's because
system-wide VM is exhausted, and some other process might return space
before you try again, but it's not very likely.
Also, some versions of Unix use "optimistic" VM allocation. When a
process requests additional VM, it always succeeds (if the process has
the virtual addresses available). Swap space is not reserved
immediately, it's only allocated as needed when any of the new pages are
modified. If no swap space is available, the process gets a signal.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
[ Post a follow-up to this message ]
|