Subject: Re: mmap() lossage??
To: Brian C. Grayson <bgrayson@ece.utexas.edu>
From: Paul Kranenburg <pk@cs.few.eur.nl>
List: netbsd-help
Date: 04/26/1997 15:32:07
>   Is there anything I am forgetting to do in this program?  I
> thought munmap() should do everything I want.
> 

> void * mmapalloc(size_t len) {
>   void * p;
>   p = (void*) mmap(0, len+0x0fff, PROT_READ|PROT_WRITE,
			    ^^^^^^

You're mapping more than you're unmapping later.

This not only keeps addresses (which you've not touched) in your process
address space, but due to an artifact in the VM system, also holds on
to the memory allocated for the one page (per iteration) that you do
touch.

-pk