Linux

Clearing Memory Cache and Swap Linux – Ubuntu

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

 

 

Criei este Blog destinado a desenvolvedores e interessados na Tecnologia Oracle SOA Suite, minha idéia é que no futuro ele sirva de referência para Analistas e Desenvolvedores desde aprendizes a especialistas. Já existem alguns Posts interessantes que abordam um pouco do meu dia a dia, no passar do tempo irei alimentar este Blog com o máximo de informações possíveis, por isso peço por gentileza aos interessados e afins que caso tenham alguma dúvida, sugestão ou crítica que me digam para que eu possa da melhor forma suprir as expectativas e na medida do possível sanar todas as duvidas que vierem a surgir ou até mesmo criar novos Posts abordando algum tópico que venha a ser relevante para todos os interessados. Obrigado Uans Carvalho

Leave a Reply

Your email address will not be published. Required fields are marked *