Webhosting Blog

Clearing filesystem memory cache

The new linux kernels provide us the provision to clear page cache and/or inode and dentry caches  which can help free to clear a lot of memory.

Following command can help you to check the memory usage.

[root@server~]# free -m

In order to free  pagecache use following command:

[root@server~]# echo 1 > /proc/sys/vm/drop_caches

In order to free dentries and inodes:

[root@server~]# echo 2 > /proc/sys/vm/drop_caches

In order to free pagecache, dentries and inodes:

[root@server]# echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable. So run a sync command for this.

[root@server]# sync; echo 3 > /proc/sys/vm/drop_caches


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s