Search This Blog

Thursday, May 27, 2010

Can I free memory by flushing the pagecache and the slabcache in Red Hat Enterprise Linux?

http://kbase.redhat.com/faq/docs/DOC-5411


http://kbase.redhat.com/faq/docs/DOC-7055

http://kbase.redhat.com/faq/docs/DOC-7986

http://kbase.redhat.com/faq/docs/DOC-4302

http://kbase.redhat.com/faq/docs/DOC-3368



> For example with 8GBs of total memory the Cache is using 6GBs. I would like to restrict the cache to 2 or 3 GBs. Well , there is no direct method by which you can set restrict the cache to 2 or 3 GB's. Since this is entirely maintained by the Linux kernel.

You can still tune the following parameters of /etc/sysctl.conf in such a way that the kernel does less page caching.

vm.pagecache vm.vfs_cache_pressure vm.drop_caches vm.swappiness

1) The following command can be used to free the pagecache:
echo 1 > /proc/sys/vm/drop_caches

You can see the effect by comparing the output of "free -m" before and after running the above command

For more details: - http://kbase.redhat.com/faq/docs/DOC-5411

2) Setting the vfs_cache_pressure value higher than 100 increases the kernel's willingness to reap caches of filesystem metadata. Kernel frees lowmem more frequently thus reducing fragmentation.

vm.vfs_cache_pressure=200

For more details: - http://kbase.redhat.com/faq/docs/DOC-4302

3) Lowering vm.swappiness will make the system reclaim page cache first, before swapping. A value of 20 should be fine, maybe even lower.
# echo '20'> /proc/sys/vm/swappiness


For more details check : - http://kbase.redhat.com/faq/docs/DOC-3368

Let me know if you need further explanation.

No comments: