nhaas writes:
This is normal memory usage, the system is cacheing filesytem use and storing it in ram.
If the usage grows at a much faster rate then become concerned.
So when does the memory ever get released. It just grows and grows and grows. Out of 2 gigs I have 19,124k free and starting on swap 8k used. Should I not be alarmed on this? An old UNIX guy is telling me that = there is a memory leak somewhere....
Typically the memory used by the cache will be persistent until
some user process allocates more memory than there is available memory,
then the kernel will free up the cache memory and flush data to
disk if needed.
Linux takes the philosophy that "free memory is bad memory". If
memory isn't used then it's a waste of resources, why not use what
it could for filesystem cache (for performance)?
I have been running "xosview" to monitor memory usage, and the
blue portion of the MEM bar graph is actual program use, the orange
for kernel buffering, and the red for filesystem cache. Typically
the red will grow and fill up almost all of the memory. However
if a user program attempts to allocate a lot of memory, then the
cache use will decrease.
I wrote a test program in C that demonstrates this phenomenon.
The source code is included below. Compile this program and run it
when your physical memory is all used up. Watch the MEM bar in
"xosview" while you do this. Save the contents between the "snip"
lines into a file "allocmem.c", then compile as follows in a konsole
window:
gcc -O -o allocmem allocmem.c
To run, use the following syntax:
./allocmem n
Where n is the number of megabytes you want this program to attempt
to allocate. The program will allocate the memory, and if successful,
write to all pages of the allocated memory, and then free it and exit.
If you ask for more memory than what could be freed from buffer and
cache, then the kernel will page out other program memory to your
swap device. You'll see the SWAP bar in xosview increase.
Here is the code:
-----------X snip X-----------
/* @(#)allocmem.c 1.1 04/08/18
*
* allocmem
*
* A program to test memory allocation
* Usage: allocmem n
* where n is the number of megabytes to allocate.
*
* Ti Kan
*/
#include