From owner-freebsd-questions@FreeBSD.ORG Tue Dec 2 11:42:41 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED7371065675 for ; Tue, 2 Dec 2008 11:42:41 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 32BB98FC16 for ; Tue, 2 Dec 2008 11:42:40 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (adsl142-13.kln.forthnet.gr [195.74.241.13]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id mB2BgM20022317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 2 Dec 2008 13:42:28 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id mB2BgMeD009753; Tue, 2 Dec 2008 13:42:22 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id mB2BgLtn009752; Tue, 2 Dec 2008 13:42:21 +0200 (EET) (envelope-from keramida@freebsd.org) From: Giorgos Keramidas To: yuri@rawbw.com References: <49345710.9070403@rawbw.com> <874p1njz3l.fsf@kobe.laptop> <49346BD3.5080506@rawbw.com> Date: Tue, 02 Dec 2008 13:42:20 +0200 In-Reply-To: <49346BD3.5080506@rawbw.com> (yuri@rawbw.com's message of "Mon, 01 Dec 2008 14:57:23 -0800") Message-ID: <87ljuy2483.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: mB2BgM20022317 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.22, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.18, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: Why process memory starts so high up in virtual space with FreeBSD malloc? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2008 11:42:42 -0000 On Mon, 01 Dec 2008 14:57:23 -0800, Yuri wrote: > Giorgos Keramidas wrote: >> The FreeBSD malloc(3) implementation can use either mmap() or sbrk() to >> obtain memory from the system. It does not 'waste a high percentage of >> memory' but it simply maps only high addresses (with an unmapped 'hole' >> in lower addresses). > > But the hole it leaves with MALLOC_OPTIONS='dM' is way larger than the > one left by 'Dm' option. Usually malloc will keep allocating addresses > higher than this initial value and will never come back and fill some > parts of this gap. Therefore "wasting" this space. The 'D' and 'M' options set what malloc() will _prefer_, they do not force malloc() to use _only_ the particular type of memory space. As Dan explained in another post, both memory types will be used if there is need for more address space.