[comp.unix.ultrix] Will Ultrix free

D. Allen [CGL]" <idallen@watcgl.waterloo.edu> (10/30/90)

main()
{
	char *p;
	extern char *malloc();

	system("/bin/sh");
	p = malloc(8*1024*1024);
	system("/bin/sh");
	free(p);
	system("/bin/sh");
}

Run "ps laxwwt" and ^D (EOF) at each sh prompt and see that Ultrix
never takes back the 8Mb freed by the process.

Nice Unix systems reset the process brk() memory limit back down
after freeing the 8Mb.  Ultrix 3.1C does not.  You're stuck with the
high-water mark (and 8Mb of wasted swap) for the life of the process.

Is this the same in Ultrix 4.[01]?  Anyone have a nicer malloc/free
that knows how to do this?  I'd like to feed it to my X server...
-- 
-IAN! (Ian! D. Allen) idallen@watcgl.uwaterloo.ca idallen@watcgl.waterloo.edu
 [129.97.128.64]  Computer Graphics Lab/University of Waterloo/Ontario/Canada

rusty@belch.Berkeley.EDU (rusty wright) (10/31/90)

Notice that (on Ultrix 3.1 at least) the malloc man page says for
free:

	The argument to free is a pointer to a block previously
	allocated by malloc. This space is made available for further
	allocation, but its contents are left undisturbed.

I think it's historical and has something to do with the way malloc,
free, and realloc work/interact.  This is also what the man page says
for 4.3bsd, so I guess 4.3bsd isn't a "nice Unix system" either.