Re: Avoiding OOM on overcommit...?

From: Andreas Bombe (andreas.bombe@munich.netsurf.de)
Date: Sat Mar 25 2000 - 11:52:39 EST


On Sat, Mar 25, 2000 at 02:27:43AM -0500, Sandy Harris wrote:
> James Sutherland wrote:
>
> > >> >BUT "when I use up the resources given to me" - If the resources
> > >> >weren't available, why did the system give them to me?
> > >>
> > >> It didn't.
> > >
> > >If he did a [mc]alloc to ALLOCate the the memory and got a non-null
> > >return, it certainly said it did.
> >
> > No - malloc() doesn't allocate MEMORY, it allocates ADDRESS SPACE to
> > put memory in later. This may not be what you wanted, but that's what
> > it does.
>
> Both 'man malloc' and 'info malloc' on my SuSE 6.3 system say it
> "allocates memory". At the very least, these pages need some text in
> the BUGS section explaining what they actually do.

malloc() is not a kernel function, it's a libc function. This
function is implemented to first try to use already available memory
from the heap space (i.e. free()d memory) or get some more heap space
if there is no chunk available that's big enough. The relevant kernel
function for that is brk() (or mmap() for bigger chunks). Their man
pages say nothing about "allocating memory".

> Also, you describe what malloc() currently does on Linux, but it is by
> no means clear that that's what it should do.
>
> Checking the C standard at:

The C standard isn't relevant to the Linux kernel interfaces.

-- 
          Andreas E. Bombe <andreas.bombe@munich.netsurf.de>
http://home.pages.de/~andreas.bombe/                DSA key 0x04880A44

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:15 EST