Poul-Henning Kamp once wrote:

> >>     If you unset the datasize limit and the program does not exceed
> >>     the maximum system-supported datasize limit, malloc() should
> >>     not return NULL even if the system is out of swap.

> >Can you explain why? Our malloc(3) is a little fuzzy as to the
> >circumstances under which malloc will fail, but on Solaris, it is
> >more explicit:

> >             If there is no available memory, malloc(), realloc(),
> >             memalign(), valloc(), and calloc() return a null pointer.
> >
> >I consider being out-of-swap as having "no available memory". Wouldn't you?
> The trouble is, there is no such thing as "no available memory".

Well, this is just an implementation detail, is not it? I don't
mean to critisize, or anything, but such thing as "no available
memory" is a fairly intuitive... Coming down, again, the malloc
should return a usable memory if available and NULL if it's not.
Is not this a "natural" semantics? Why can a program die because
_another_ program ate up all the rest of the memory?

> What we have instead is "not enough memory available for this specific
> request".

> For phkmalloc I can say in particular that there is a pool for each
> size of chunk (16,32,64...2048 bytes and for pages. If you run out of
> one of these there may still be stuff in the other pools.

Then the malloc may need to take its time rearranging the pools,
or whatever... It gets it right if there is a datasize limit, right?
But the current behaviour under low-memory conditions seems wrong
to me, and is certainly different from what the Solaris' malloc(3C)


        a) this message was not meant to offend;
        b) I realize, the Solaris' malloc() may also be broken
           in many ways;
        c) FreeBSD is rightfully the OS of choice for many (including
        d) I realize, that FreeBSD is wonderfull and I myself
           use it _all_ i386 machines under my control and on
           most i386 machines outside of my control.

To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message

Reply via email to