Some more testing indicates that the problem is most likely in close, not mmap. 
 I modified the program to the following:

zool# more test.c
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>


int main (int argc, char *argv[])
{
       int rc, pid, fd;
       char *cp;
       char cmd[1024];


       pid = getpid ();
       sprintf (cmd, "procstat -v %d | grep df", pid);
       fflush (stdout);
       rc = system (cmd);
       fflush (stdout);
       printf ("----------------------------------\n");

       fd = open ("./test.c", O_RDWR);
       fflush (stdout);
       rc = system (cmd);
       fflush (stdout);
       printf ("----------------------------------\n");

       close (fd);

       fflush (stdout);
       rc = system (cmd);
       fflush (stdout);
}

The output is:

zool# ./test
85860  0x8049000  0x804a000 rw-    1    0   1   0 CN-- df 
85860 0x2805f000 0x28069000 rw-   10    0   1   0 C--- df 
85860 0x28186000 0x281ad000 rw-   13    0   1   0 CN-- df 
85860 0xbfbdf000 0xbfbff000 rwx    3    0   1   0 C--D df 
----------------------------------
85860  0x8049000  0x804a000 rw-    1    0   1   0 CN-- df 
85860  0x804a000  0x8400000 rw-    1    0   1   0 CN-- df 
85860 0x2805f000 0x28069000 rw-   10    0   1   0 CN-- df 
85860 0x28186000 0x281ad000 rw-   14    0   1   0 CN-- df 
85860 0x28400000 0x28800000 rw-    6    0   1   0 CN-- df 
85860 0xbfbdf000 0xbfbff000 rwx    3    0   1   0 C--D df 
----------------------------------
85860  0x8049000  0x804a000 rw-    1    0   1   0 CN-- df 
85860  0x804a000  0x8400000 rw-    1    0   1   0 CN-- df 
85860 0x2805f000 0x28069000 rw-   10    0   1   0 CN-- df 
85860 0x28186000 0x281ad000 rw-   14    0   1   0 CN-- df 
85860 0x28400000 0x28800000 rw-    6    0   1   0 CN-- df 
85860 0xbfbdf000 0xbfbff000 rwx    3    0   1   0 C--D df 


Open creates 2 memory allocations, one in low memory and one in high.  Close 
does not remove them.  Somewhere in the source I found a note that said that 
close on files didn’t require any action.  However, those two memory 
allocations do need to get freed.  


_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to