From owner-freebsd-current@FreeBSD.ORG Fri Jan 4 13:43:52 2008 Return-Path: Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 368D716A418 for ; Fri, 4 Jan 2008 13:43:52 +0000 (UTC) (envelope-from davidt@yadt.co.uk) Received: from outcold.yadt.co.uk (outcold.yadt.co.uk [81.187.204.178]) by mx1.freebsd.org (Postfix) with ESMTP id D72CA13C442 for ; Fri, 4 Jan 2008 13:43:51 +0000 (UTC) (envelope-from davidt@yadt.co.uk) Received: from localhost (localhost [127.0.0.1]) by outcold.yadt.co.uk (Postfix) with ESMTP id 5AAD5186A; Fri, 4 Jan 2008 13:25:48 +0000 (GMT) X-Virus-Scanned: amavisd-new at yadt.co.uk Received: from outcold.yadt.co.uk ([127.0.0.1]) by localhost (outcold.yadt.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XRtB-1i2KosG; Fri, 4 Jan 2008 13:25:45 +0000 (GMT) Received: by outcold.yadt.co.uk (Postfix, from userid 1001) id E1D5D1863; Fri, 4 Jan 2008 13:25:45 +0000 (GMT) Date: Fri, 4 Jan 2008 13:25:45 +0000 From: David Taylor To: Andrey Chernov Message-ID: <20080104132545.GA51075@outcold.yadt.co.uk> Mail-Followup-To: Andrey Chernov , freebsd-current@FreeBSD.ORG References: <20080104122149.GA17103@nagual.pp.ru> <5705.1199451431@critter.freebsd.dk> <20080104131247.GA17816@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20080104131247.GA17816@nagual.pp.ru> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freebsd-current@FreeBSD.ORG Subject: Re: sbrk(2) broken X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2008 13:43:52 -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