1

Does below command improved performance of the machine:
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

I know this is for freeing RAM. Please guide

0

3 Answers 3

2

No, it just dumps a load of stuff (slab objects and pagecache) from the system cache.

If your system is out of memory (and I mean: deep into swap usage, nothing free, hard disk churning) then yes, this might help... But not as much as:

  • Buying more RAM, it isn't expensive or hard to fit.
  • Closing something that's using lots of memory (or tabs from a browser).
  • Using something faster for swap space (eg SSD)
  • Compressing swap

So while it may work for a few seconds, if you have something rampaging all over your RAM, you'd do better just to close it, or buy it more RAM with which to rampage over. Freeing up inode and page cache isn't going to help you for long.

1

No, see How do I clean or disable the memory cache? for an indepth answer.

Cache is there to be used and to speed things up. So Linux makes full use of caching. If you do this it will takes seconds for the cache to be filled up again.

Adding hardware to your system would be more efficient (depending on what triggered your question it might be memory or a better hard disk).

0

You can also write command as:

echo 3 > /proc/sys/vm/drop_caches

The above command will free pagecache, dentries and inodes. And

sudo sync

is used to to make sure all cached objects are freed as dirty objects are not free-able and the echo operation is non-destructive.

2
  • Writing 1 to /proc/sys/vm/drop_caches will only dump the pagecache.
    – Oli
    Jul 13, 2015 at 12:34
  • Appreciate the directive @Oli Jul 14, 2015 at 13:03

Not the answer you're looking for? Browse other questions tagged .