Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. In this video you will find how to Clear RAM Memory, Cache, Buffer and Swap memory in Linux 7Find some more videos on Linux:Squid Proxy with user authenticat.
You can write to
/proc/sys/vm/drop_caches file to instruct kernel to drop clean caches, as well as reclaimable slab objects like dentries and inodes. Once dropped, their memory becomes free.
This is not recommended to clear memory cache on Linux systems, but it is safe. But clearing cache may cause performance issue with system. Since it discards cached objects from memory, it may cost a significant amount of I/O and CPU to recreate the dropped objects.
This tutorial will help you to clear memory cache on Linux/Unix system via command line.
How to Clear Cache in Linux System
There are three options available to clear cache in Linux system memory. Use one of below as per your requirements.
- Clear PageCache, dentries and inodes in cache memory
- Clear dentries and inodes only in cache memory
- Clear pagecache only in cache memory
sync command is used to increase the number of objects freed by the drop cache. Using this a user can claim more memory by clearing more dirty objects on the system.
How to Schedule Clear Memory Cache
If you have to clear buffer cache regularly, use the cronjob do it. Schedule the following in system crontab to automatically flush cache memory on a regular interval.
Open a terminal and execute ‘crontab -e’ command to edit crontab:
Append below entry to the file:
The above cron will execute on every hour and flushes the memory cache on your system.
How to find Cache Memory in Linux
Use free command to find out cache memory uses by Linux system. Output of free command is like below
Here the last column is showing cached memory (12953 MB) on Linux system. The -m option is used to show output MB’s.Best decide what to do in the beginning inside Calamares - 3 choices regarding swap.
But you can have other reasons to install calamares without swap and lateron add a swapfile to the system.
Clear Swap Linux
One of the advantages is that you can make the swapfile on the spot and delete it again. Make it bigger or make it smaller.
You can do the same with partitions via gparted but it is a bit more technical.
How to set up a swapfile on ArcoLinux or Arch Linux? of 8G = 8 Gigabyte - make bigger if needed
Now reboot and check with
Clean Swap Linux Tutorial
Code: Select all