From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,cffbc9c29a6b482a,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-10-21 04:44:58 PST Newsgroups: comp.unix.osf.osf1 Path: bga.com!news.sprintlink.net!howland.reston.ans.net!EU.net!uknet!comlab.ox.ac.uk!newshost!Ray.Bellis From: Ray.Bellis@psy.ox.ac.uk (Ray Bellis) Subject: Kernel memory leak found in OSF/1 v3.0 Message-ID: Organization: O.U. Dept. of Experimental Psychology Date: 21 Oct 1994 08:00:13 GMT 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 #include #include /* 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: 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 ------------------------------------------------------------------------------