I am using a large instance of EC2 (2 Dual Core AMD Opteron(tm) Processor 270, 7.5GB RAM), which is up since June 29th and showing availability of only 500MB of memory, in `top'. I had known the mathematics behind the RAM usage, that shows up in `top', but could not recollect.
Then, I thought that, since it had something to do with memory, why not look up `/proc/' entries. That's when I looked up the man page for `proc'. On detailed reading, I remembered the mathematics.
The used memory constitute of the `kernel buffers' and the `page cache'. See the output of `free'. Now my EC2 instance was showing almost 7GB memory used, out of which 5.5 GB was cached.
Now, I ran a small command on the shell:
echo 3 > /proc/sys/vm/drop_caches
Now, writing `3' to `/proc/sys/vm/drop_caches', clears the pagecache and dentries. To learn more, read manual page for `proc'.
When the cache was cleared, I had 6.5 GB of memory available. Usually, the cache is cleared by the Kernel, only on demand. So, if I run a program, which simply tries to use huge amount of memory, the Kernel, will clear the cache and make it available for the program to use.
Thanks da..
that was informative
Posted by: Njan | September 05, 2008 at 09:36 AM