Date: Thu, 7 Dec 2000 10:06:20 -0800 (PST) From: Matt Dillon <dillon@earth.backplane.com> To: Remy Nonnenmacher <remy@boostworks.com> Cc: phk@critter.freebsd.dk, freebsd-hackers@FreeBSD.ORG Subject: Re: free() not freing pagedirs pages. Message-ID: <200012071806.eB7I6KX10417@earth.backplane.com> References: <200012071200.NAA35634@luxren2.boostworks.com>
next in thread | previous in thread | raw e-mail | index | archive | help
:Well, I may think using this solution if it remains portable between
:Unixes. I finally tracked down the problem, after suppressing the
:reason to call __smakebuf and tooling malloc.c.
:
:What happens is that malloc() uses the pages to store pginfo chains. If
:all memory is used, it allocates high addresses pages and (seems
:to) keeps these pages when all memory have been freed().
:
:Here is a case: In the following example, about 60 Mbytes have been
:allocated then freed. Only one structure remains allocated at the very
:beginning of the memory (It is the first one allocated).
:
Another thing you can do, if you really want to continue to use mmap(),
is to malloc() a large chunk of memory and then allocate the smaller
structures out of the large chunk. That way you can free the large chunk
all in one go. If the smaller structures are all the same size, writing
a little support code to do this is trivial. If not, then you can use
a simple zero-overhead allocator such as the one I wrote for libstand,
/usr/src/lib/libstand/zalloc*, to allocate out of the big chunk you
malloc'd.
Whatever you do, do *NOT* depend on malloc being able to clean up small
allocations and release their underlying pages. It might work in
FreeBSD under certain circumstance, but it isn't a portable assumption.
-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?200012071806.eB7I6KX10417>
