In this article, we would teach you the instructions to clear cache buffer and swap memory in Linux so that you can use them if needed or if the RAM is full and the system is slow, so that you would have more space on RAM.
Tutorial How to clear cache buffer and swap memory in Linux
What is cache and buffer basically?
As you know, every operating system uses cache, buffer, etc. to run its processes as well as increase the operating speed of the operating system. Accordingly, to manage and clear cache, buffer, and Swap memory in Linux, it provides a way for your users to delete them if necessary. Linux is no an exception, even it uses a much better operating system than any other operating system.
How to free space on RAM buffer and swap in Linux
There are three ways to remove cache, buffer, etc., which are:
1- To delete only Page Cache, so you can enter the following command:
sync; echo 1 > /proc/sys/vm/drop_caches
2- If you need to delete the created Dentries and Inodes, you must enter the below command:
sync; echo 2 > /proc/sys/vm/drop_caches
3- Finally, if you want to delete all page Cache, Dentries and Inodes, you must enter the command in this way:
sync; echo 3 > /proc/sys/vm/drop_caches
From now on, you are familiar with the function of the Sync command, and you can use it to clear the cache.
Do’s and don’ts
Please be aware to use this command just at certain times and when a Linux server has not been restarted for a long time.
Repeated use of this command may interrupt the performance of Linux and run kernel processes, so avoid using it frequently.
Also, you can use this command in Cron to automatically perform a cleanup after 24 or 48 hours of high pressure on the server.
Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problem in it as soon as possible. Make time for other users and experts to answer your questions.