How to clean inactive memory or caches in Linux

First check the memory Utilization

[root@ localhost ~]# vmstat -s -S m
8066 m total memory
7932 m used memory
<pre> 2051 m active memory
5508 m inactive memory
134 m free memory
3197 m buffer memory
3897 m swap cache
.
.
output omitted…

Now run following commands as required to clean inactive memory/caches

NOTE: run commands with root or sudo users

To clean page-cache:

[root@localhost ~]#sysctl -w vm.drop_caches=1

OR

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

To clean dentries and inodes:

[root@localhost ~]#sysctl -w vm.drop_caches=2

OR

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

To clean page-cache, dentries and inodes:

[root@localhost ~]#sysctl -w vm.drop_caches=3

OR

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

 

🙂


Posted

in

by

Comments

Leave a Reply