Linux does a good job when it comes to memory allocation. If memory isn’t being used or hasn’t been used for awhile it gets put into a cache where it can readily pulled. At times though this cache can become pretty big (especially for a program that has a memory leak). If a good number of programs are being used or if memory is limited then Linux will begin using hard disk swap which can really bog down performance. In these instances, it may help to purge the memory.
In the terminal type
free -m to see memory usage. Flushing the filesystem buffers and to drop extra caches can be done by doing:
sudo sync sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
Look once more at
free -m and memory usage should be improved. Freeing memory is most effective by shutting down whatever programs can be. To be really effective shutdown X server first.
This can be put in a script if you need to regularly do this: