*BSD News Article 5785


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!cs.mu.OZ.AU!mundil.cs.mu.OZ.AU!johnp
From: johnp@mundil.cs.mu.OZ.AU (John Steve PETROU)
Subject: free() - not working properly
Message-ID: <9227414.18251@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
Date: Wed, 30 Sep 1992 04:13:16 GMT
Lines: 38



I was wondering if anyone else has had the same problems as me with
free().

I am running a 486 with 8MEG of memory and 16MEG of swap space. I am
currently using the kernel supplied with the lasest release of X386, but
have had the same problem with other kernels.

If a process mallocs and frees memory durings its normal execution, I find
that ps -axv reports that the VSZ is always growing. I first noticed it
while using xman. The more manual enteries I read the more I noticed disk
activity increasing. (I closed each page after reading it BTW). ps -axv
showed that the more I used xman the greater the VSZ. I found the same thing
with xgif, after increasing the size of an image the VSZ increased as
expected but wouldn't decrease when the image was reduced. I wrote the
following couple of lines to test the problem out of X386, and the same
problem could be seen. 

main()
{
	int i;
	char *p. c;

	while(1) {
		if((c = getrchar()) == 'q') exit(0);
		p = (char *)malloc(100000 + 10000 * i++);
		free(p);
	}
}

I checked VSZ after a few loops and it just kept growing. I have also 
noted that the more often these programs are run the worse the performance
due to excessive swapping.

Is this a problem ?
Thanks
John Petrou