HOW TO CLEAR SWAP CACHE

Recently we have talk about a script to calculate the swap usage and activated the alert when Swap usage hit the certain stage.

And I discovered out the real memory utilization is not using as it is where swap still caching the usage.

To clear the swap cache,First of all, you need to identify the swap disk. Check the blkid for more information.

blkid

Locate the entry of swap, Assuming swap is in sda5.

Turn the swap cache off:

swapoff /dev/sda5

Once it is done, turn it on again:

swapon /dev/sda5

Done.