Date: Thu, 7 Dec 2000 10:01:24 -0800 (PST) From: Matt Dillon <dillon@earth.backplane.com> To: Dag-Erling Smorgrav <des@ofug.org> Cc: remy@boostworks.com, phk@critter.freebsd.dk, freebsd-hackers@FreeBSD.ORG Subject: Re: free() not freing pagedirs pages. Message-ID: <200012071801.eB7I1OF10367@earth.backplane.com> References: <200012071200.NAA35634@luxren2.boostworks.com> <xzp66kwpf0a.fsf@flood.ping.uio.no> <xzp1yvkpe82.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
:
:Dag-Erling Smorgrav <des@ofug.org> writes:
:> Remy Nonnenmacher <remy@boostworks.com> writes:
:> > Well, I may think using this solution if it remains portable between
:> > Unixes.
:> It's perfectly portable, with one small variation - on BSD systems,
:> you pass -1 instead of a file descriptor, while on SysV systems, you
:> pass a descriptor to /dev/zero (or was it /dev/null?)
:
:FWIW, I just did some tests - mmap()'ing /dev/zero works on FreeBSD as
:well, and mapping the same fd multiple times gives you separate areas,
:so you don't need a new fd for each.
:
:DES
:--
:Dag-Erling Smorgrav - des@ofug.org
There are three ways to use mmap() to allocate memory:
#1 MAP_ANON, when supported, should be used.
#2 /dev/zero, when supported, should be used (tends to be more portable
then MAP_ANON).
#3 Create a temporary file, hold the descriptor, remove() the file,
ftruncate() to the proper length, then mmap using MAP_PRIVATE. And
then you can close the descriptor. This actually takes up *NO*
filesystem space, since it's a private map.
You can also keep the descriptor around and allocate/free chunks
using mmap()/munmap() out of it. Just remember that you have to
ftruncate() the file to be big enough to 'hold' your mmap ranges.
This tends to be the most portable.
Which of the three one uses depends on the OS.
-Matt
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?200012071801.eB7I1OF10367>
