Very often I used to find that my Linux box(s), Fedora & Ubuntu both started reserving more RAM over a period of time since its boot. And the actual RAM left free was less.
I knew it was holding some caches for itself so that it could find the programs loading “quickly” and something like that (Sorry for my newbie language).
The most common way to free up RAM is Rebooting! But I wanted to avoid it, so did a little “googling” and I came up with an interesting solution – Tell linux to flush all the caches.
# Flush file system buffers by executing sync; # free page cache echo 1 > /proc/sys/vm/drop_caches; # free dentries and inodes echo 2 > /proc/sys/vm/drop_caches # free page cache, dentries and inodes echo 3 > /proc/sys/vm/drop_caches
I’ve created a simple bash script, which u can download.
Kill it…
Thanks Ruturaj. This is imagine…it helps for my production LINUX issue
Hi. I’m trying to make it simpler by just double-clicking it and do the job unsuccesfully. It works if i run it as root from terminal, or if I open it as root(right-click –> open as root –> type password) and then run it.
But I was wondering if this could be easier, double-click it and that’s all.
I’d appreciate an answer if anyone knows how to do that..
I’m not really sure how to do it – But the script will have to accept root / authentication just like yumex does.
Or you could simply add ur user id as admin
Thanks for sharing this wonderful article. I would like to add a command to it:
free -m
This will free up cached memory.
Hey Mandar, It just displays the free memory in mega bytes. Check
man free
way to useful, thanks for sharing yo
This is great. Thanks for sharing 🙂
Thanks a lot. This worked like a charm
Thanks! Although I prefer to use sysctl for that. For example, in Ubuntu I use:
sudo sysctl vm.drop_caches=1
sudo sysctl vm.drop_caches=2
sudo sysctl vm.drop_caches=3
This saved me a lot of time. Thanks!
wonderful! Trying it on elementaryOS.
You can delete the cache entries, but this will make no difference to the amount of memory your applications can use. The caching will free up memory as soon as an application needs the memory. So the only thing you do is slowing things down because all the cached applications will have to be searched for on the harddisk again.
Works like a charm. Thankx