Tags

, , , , ,

When you need to clear the memory on Ubuntu Linux Cache and Swap ?

Depends…. If you do not use your Ubuntu at very high frequency processing and memory perhaps will never need, but we developers who use the tools increasingly require our hardware is extremely important cleanse our memory in the most extreme cases of local tests, so this post will name just a very simple script that I use in my daily life which for me is very effective and I hope for you too  🙂

Open your command prompt in Ubuntu and enter the command as follows:

  • gedit limpezaCacheSwap.sh

Here a call file is created limpezaCacheSwap.sh

Within this file paste the content below:

echo “clearing Cache and Swap…”

echo 3 > /proc/sys/vm/drop_caches
sysctl -w vm.drop_caches=3
swapoff -a && swapon -a
clear
echo “Cleaning the Cache and Swap was successful

Save and Close the file:

Now go back to your prompt and give the necessary permissions to execute the file.

  • sudo chmod 755 limpezaCacheSwap.sh

Run the command below to see how your in MB Cache memory:

  • free -m

To run your always remember file to run it with SUDO

  • sudo ./limpezaCacheSwap.sh

Now run the command again:

  • free -m

 

 

Note: I stressed the test in Ubuntu because I have not tested these commands in other Linux distribution.

 

Hugs and to the Next

/:-D