Last Updated: December 26, 2018
·
471
· mcappadonna

Freeing cached memory on linux system

Sometimes you can see a piece of your ram in the state "cached" by the linux kernel.

Expecially on the systems with poor memory, you can give a breath of fresh air to your linux machine, freeing the cache:

For example, on my simple ntp server, I've this situation:

# free -m
             total       used       free     shared    buffers     cached
Mem:           249        241          7          0          2        147
-/+ buffers/cache:         90        158
Swap:         1027        138        889

Whoa, a lot of memory in "cache" state (compared to the free one).
So, you can simple launch this command:

# sync; echo 3 > /proc/sys/vm/drop_caches

And you're done!

# free -m
             total       used       free     shared    buffers     cached
Mem:           249        110        138          0          0         19
-/+ buffers/cache:         90        158
Swap:         1027        138        889

Enjoy