This article covers how to clear the cache and buffer memory of the physical memory along with clearing the swap space when needed.
Every Linux System has three options to clear cache without interrupting any processes or services.
If you want to clear Swap space, you may like to run the below command.
$ swapoff -a && swapon -a
To Clear PageCache, dentries and inodes:
$ sync; echo 3 > /proc/sys/vm/drop_caches
To Clear PageCache only:
$ sync; echo 1 > /proc/sys/vm/drop_caches
To Clear dentries and inodes:
$ sync; echo 2 > /proc/sys/vm/drop_caches