Re: sbrk(2) broken

From: David Taylor <davidt_at_yadt.co.uk>
Date: Fri, 4 Jan 2008 13:25:45 +0000
On Fri, 04 Jan 2008, Andrey Chernov wrote:

> On Fri, Jan 04, 2008 at 12:57:11PM +0000, Poul-Henning Kamp wrote:
> > There is address space allocated to the process (via sbrk/mmap)
> > 
> > A subset of this, is address space allocated by the program (via malloc)
> > 
> > ...and then there is memory actually in use, which is an entirely different
> > thing, of which we currently only have some kind of clue in the VM
> > system.
> 
> Then, we need sysctl to fetch that "memory actually in use" from the 
> kernel and compare that with getrlimit() which allows malloc() to return 
> 0 when needed.

That won't help much -- malloc could have allocated some address space that
hasn't (yet) been touched by the process.  Just returning 0 when the
amount of memory "in use" hits a limit wouldn't stop the process from
then touching all the memory it has previously been allocated and
exceeding the limit.

-- 
David Taylor
Received on Fri Jan 04 2008 - 12:43:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:24 UTC