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
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:
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.
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).
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.