RAM Management #
Freeing Stale Caches (drop_caches)
#
On a Linux system, a fraction of the system memory can be reclaimed by dropping kernel caches.[1] We can use the following commands to achieve this.
To free pagecache:
sync && echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
sync && echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
sync && echo 3 > /proc/sys/vm/drop_caches
So, the last one combines the effect of commands 1 and 2.
These commands must be executed under the
rootshell. Withsudowe can either need to enter the root shell first or execute the commands withsh[2]sudo sh -c 'sync && echo 1 >/proc/sys/vm/drop_caches'