On 6/10/06, Ronald G Minnich <[email protected]> wrote:
David Leimbach wrote:
> On 6/9/06, Ronald G Minnich <[email protected]> wrote:
>
>> Latchesar Ionkov wrote:
>> > Another example is using emalloc in libraries. I agree that it is much
>> > simpler to just give up when there is not enough memory (which is also
>> > not very likely case), but is that how the code is supposed to be
>> > written if you are not doing research?
>>
>> yes, that is a problem with a lot of code. "Just bail on first error" --
>> we've had to stop using emalloc here because that is very unrealistic
>> for production support.
>>
>> ron
>>
>
> Well I wonder what people typically do when they can't malloc anymore
> memory but need more... A reasonable thing to do is to die I'd think.
example.
xcpu server is running a couple hundred processes for testing. It is
asked to do one more. It can't allocate something.
Just dying at that point is really a bad idea, and we did find that some
of the libraries we were using would in fact do that, without coming
back to xcpu server main code with an error. That's not good behaviour
for xcpu server. It should gracefully return 'no more room' and keep
managing things; in some few cases, the library did not give us that
option.
I agree with you wholeheartedly. However there are times when you
*need* to malloc more memory but can't, based on how the program in
question is supposed to operate.
Having implemented parts of MPI's Dynamic Process Management
specification before, I totally understand where you're going.
I do find that, however, when I need to malloc more memory, not
getting what I ask for from malloc is not an acceptable run of the
program. This happens to me more often than the recoverable cases in
fact, so I often call "abort" when malloc comes back NULL (in testing
anyway... core dumps are handy).
There are lots of cases like this, many of them in the kernel even;
would we want the kernel to just toss chunks at these times?
Well in the kernel I agree it's a totally different ball game. There
are blocking and nonblocking memory allocators (in linux anyway).