Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Kernel memory leak found in OSF/1 v3.0
@ 1994-10-21  8:00 Ray Bellis
  0 siblings, 0 replies; only message in thread
From: Ray Bellis @ 1994-10-21  8:00 UTC (permalink / raw)


I've found out that there is a memory leak in the /proc file system
handling under OSF/1 v3.0.  I've reported the problem to my CSC who
should hopefully have a fix to me fairly soon.

The leak occurs whenever a process opens an entry in /proc for any
process other than itself.  Each time this happens the kernel allocates
512 bytes of memory for itself and adds it to the TEMP pool.

The reason I was particularly susceptible to this leak is that we use
the `autonice' daemon that I wrote.  Once a minute, the daemon opens
every file in /proc.  On a typical system here with 80 processes running,
this bumps up the kernel size by 40 kB per minute, or 2.4 MB per hour.
On a 32 MB machine it doesn't take that long before all memory is
exhausted, at which point the kernel fails to allocate an `mbuf' and
the system falls over *without rebooting*.

Anyway, here's a simple program which demonstrates the bug.

--8<--8<--
/*
 * memleak.c for OSF/1 v3.0 and /proc fs
 * R.P.Bellis 1994
 */

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

/* ARGSUSED */
int main(int argc, char *argv[])
{
	FILE		*fp;
	char		 path[80];

	/* Get path name for *parent* process */
	sprintf(path, "/proc/%05d", getppid());

	/* Open the file */
	if ((fp = fopen(path, "r+")) == 0) {
		perror("fopen");
		return EXIT_FAILURE;
	}

	/* Close the file */
	fclose(fp);

	return EXIT_SUCCESS;
}
--8<--8<--

Compile the program, and each time you run it, you'll see the TEMP pool
size increase by 512 bytes (from `vmstat -M').

Ray.
--
------------------------------------------------------------------------------
R. P. Bellis				E-Mail:	<Ray.Bellis@psy.ox.ac.uk>
Computing Officer
MRC Centre in Brain and Behaviour
Dept of Experimental Psychology
University of Oxford
South Parks Road			Tel:	+44 1865 271359
Oxford OX1 3UD				Fax:	+44 1865 310447
------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1994-10-21  8:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-10-21  8:00 Kernel memory leak found in OSF/1 v3.0 Ray Bellis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox