Clear RAM Memory Cache, Buffer and Swap Space on Linux. Have you ever have any process is eating away your memory and you want to clear it, Linux provides a way to flush or clear ram cache. How to Clear Cache in Linux? Every Linux System has three options to clear cache without interrupting any processes or services. Clear PageCache only. Linux borrows unused RAM memory for disk caching due to this it looks like the system is low on memory. Usually you don’t need to do anything to clear this memory as Linux automatically manages the RAM and will allocate the cached memory when ever a application asks for the same. Dropcaches Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. First - the echo command you gave should be clearing the page cache. This is the same command given here. The page cache is managed by the kernel. It is not used (at least directly) by any process. The memory used by the page cache is available to be given to any process if the kernel decides to do that. The memory has not been leaked.
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?
Linux Drop Cache
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:
How To Clear Cache Memory In Linux
1- To delete only Page Cache, so you can enter the following command:
2- If you need to delete the created Dentries and Inodes, you must enter the below command:
3- Finally, if you want to delete all page Cache, Dentries and Inodes, you must enter the command in this way:
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.
Unable To Clear Cache Memory In Linux
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.