: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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to