How to Delete Memory Buffers and Cache in Linux

Deleting the buffers and cache reduces the performance of the Linux system! If you’re here because you thought that freeing buffers and cache was a positive thing, go and read Linux ate my RAM!. The short story: free memory is unused memory is wasted memory.

How to Empty the Buffers Cache on a Linux System?

If you ever want to delete the buffer’s cache, you can use the following chain of commands like free, sync, and echo.

[root@linuxshelltips:~]# free && sync && echo 3 > /proc/sys/vm/drop_caches && free

              total        used        free      shared  buff/cache   available
Mem:        1008876      468376       98244       19468      442256      359588
Swap:       5242876         524     5242352
              total        used        free      shared  buff/cache   available
Mem:        1008876      427588      450300       19468      130988      424732
Swap:       5242876         524     5242352

The above is meant to be run as root. If you’re trying to do them using sudo then you’ll need to change the syntax slightly to something like these:

[user@linuxshelltips:~]$ echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh

If you have any other Linux tips, questions, or doubts? do ask for help in the comments section.

Got something to say? Join the discussion.