Memory leak in the ramfs file system

Stephen L Johnson (sjohnson@monsters.org)
Thu, 29 Mar 2001 16:06:54 -0600


A group of us from the handhelds.org site think that we have found a memory
leak in the ramfs file system. After a long period of create and deleting
small files in a mounted ramfs partition we have substantially less freemem.
The problem has been confirmed on 2.4.2 on an i386 and StormARM ports.

The problem was found by a developer running an application on an iPAQ that
quickly writes a 4K file to the ramfs, does some editing of the file and it
then deleted. The application will quickly eat up all free memory and cause
the platform to fail within 5 minutes.

Test case: from a shell, run this short script for a long period of time (over
1 hour):

i=0 ; while : ; do echo 1 >$i ; rm $i ; i=`expr $i + 1` ; done

This test was run on an Compaq iPAQ 3650 using the 2.4.2-rmk1-np3 kernel from
the CVS repository on cvs.handhelds.org.

The following two data points are the output from /proc/meminfo. The first
'cat' was done about 1 minute after the loop has been running. The second
'cat' was done 10 minutes after the script loop had been killed.

# cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 31686656 21446656 10240000 0 0 11264000
Swap: 0 0 0
MemTotal: 30944 kB
MemFree: 10000 kB
MemShared: 0 kB
Buffers: 0 kB
Cached: 11000 kB
Active: 4656 kB
Inact_dirty: 4220 kB
Inact_clean: 2124 kB
Inact_target: 0 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 30944 kB
LowFree: 10000 kB
SwapTotal: 0 kB
SwapFree: 0 kB

# cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 31686656 24178688 7507968 0 0 12357632
Swap: 0 0 0
MemTotal: 30944 kB
MemFree: 7332 kB
MemShared: 0 kB
Buffers: 0 kB
Cached: 12068 kB
Active: 4560 kB
Inact_dirty: 5384 kB
Inact_clean: 2124 kB
Inact_target: 16 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 30944 kB
LowFree: 7332 kB
SwapTotal: 0 kB
SwapFree: 0 kB

--
Stephen L Johnson  <sjohnson@monsters.org>

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/