In my Web Analytics company, I occasionally had problems with Linux servers, because they tended to cache a lot of stuff. Especially, this problem occured, when I was manually copied a lot of files or was doing a tar backups for one of our clients. Well, there is an easy  solutions for this issue now

Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache…

To use /proc/sys/vm/drop_caches, just echo a number to it.

To free page cache:

# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, the user should run “sync” command first!

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like
Read More

Download using wget

You can use “wget” on Linux machine CLI to download files from http or ftp sites. Proxy configuration…
Read More

Simple perl ipcalc

Here is a simple program to calculate Network address and broadcast address, given input of IP address and…