How to flush RAM on Linux / Centos

I personally suggest using first option, other are more and more “hardcore”. Also I would not suggest doing this under high CPU load or high disk activity, as they both rely on this cache and it might either hang the whole server or create even higher load.

To free pagecache:

 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

To flush swap (this will give a lot of load on your disk):

 swapoff -a 
 swapon –a
Facebooktwittergoogle_plusredditpinterestlinkedinmail