Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Feb 2001 20:36:23 +0900
From:      "Daniel C. Sobral" <dcs@newsguy.com>
To:        Dag-Erling Smorgrav <des@ofug.org>
Cc:        Peter Seebach <seebs@plethora.net>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Setting memory allocators for library functions.
Message-ID:  <3A98EE37.7B0B6CE0@newsguy.com>
References:  <200102241643.f1OGhw616627@guild.plethora.net> <xzpg0h37rlq.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smorgrav wrote:
> 
> seebs@plethora.net (Peter Seebach) writes:
> > Is there any hope that, some day, a setting could be provided where a program
> > could request that malloc *NOT* overcommit?  There are programs which would
> > rather know in advance, and clean up, than be killed abruptly.
> 
> Malloc() does not overcommit - the kernel does. Malloc() doesn't know
> and doesn't care.
> 
> I imagine you could add a compile-time option that forces obreak()
> (why do we still use brk()/sbrk()?) to prefault the newly allocated
> address space. Or you could write a malloc() implementation that only
> uses mmap(), and add a flag value that makes mmap() prefault pages,
> and fail if there isn't enough memory available.
> 
> None of these solutions are portable, however; the portable way around
> memory overcommit is to write a malloc() wrapper that installs a
> SIGSEGV handler, then tries to dirty the newly allocated memory, and
> fails gracefully if this causes a segfault. Untested code:

None of these solutions will work. In all of the above cases, it is
still possible for an application to be killed due to out of memory
conditions caused by other applications. The main point of
non-overcommitting applications is to avoid that.

Personally, I like AIX solution of a SIGDANGER signal, and having
applications that do not have a handler installed be killed first. But
that isn't what is being asked for.

OTOH, the *only* way to get non-overcommit to FreeBSD is for someone who
*wants* that feature to sit down and code it. It won't happen otherwise.

-- 
Daniel C. Sobral			(8-DCS)
dcs@newsguy.com
dcs@freebsd.org
capo@kzinti.bsdconspiracy.net

	Acabou o hipismo-arte. Mas a desculpa brasileira mais ouvida em Sydney
e' que nao tem mais cavalo bobo por ai'.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A98EE37.7B0B6CE0>