Subject: calloc() and free() ps doesn'r report memory being freed, why?
To: 'netbsd-help' <netbsd-help@NetBSD.ORG>
From: John Maier <JohnAM@datastorm.com>
List: netbsd-help
Date: 07/29/1996 09:46:00
I have been hacking on ftpd so I can add an alternate ftp password   
filelist.  This allows me to give explicit access to individule without   
compromising system security.  Also I can allow others to administer the   
auxiliary ftp passwords with out having to give them su privlages.

I added a feature to allow the sub-administrator the ability to limit   
logins to a particular number of logins (3 in my case).  To do this I   
added a function that is called after a correct password has been   
entered.  I noticed, however, that the ftpd proccess memory usage went   
through the cealing!  On a 64Meg machine, which I have never seen in   
swap, I now get up to 14Megs into swap.

I am using free() like a good boy, by ps -maux shows VSZ=2264 and   
RSS=2052.  On a anonymous FTP login (which by-passes this function) The   
memory usage, as reported by ps, is VSZ=196 and RSS=520.

So what am I doing wrong?  Do I need to worry about this?  Is there   
something I can do to get the OS to compact the memory for a proccess?

Thanks
jam


/* code fragment */
int ReduceLogin(char *szUser)
{
 unsigned int iCnt=0;
 int iState=0;
 passwdfile *password[NUMBER_OF_ENTRIES];

 *password = calloc(NUMBER_OF_ENTRIES, sizeof(passwdfile));
 
 /* manipulate data */
 ~
 ~
 ~
 ~
 /* end data manipulation */

 free(*password); /* added out of desparation */
 free(password);  /* free the gobs (1.5 Meg) of memory allocated */
 return iState;
}