Clear cache memory on Linux Systems

Sometimes, you can see that memory is not correctly released once used and some caching can remain.

You can see that by using the free command:

# free -m
             total       used       free     shared    buffers     cached
Mem:         64458      53397      11060          0       1550      49163
-/+ buffers/cache:       2683      61774
Swap:         9998         35       9963

At this time, you can so free this cache and release memory by using this command:

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

Now, you can check again:

# free -m
             total       used       free     shared    buffers     cached
Mem:         64458       1162      63295          0          1         32
-/+ buffers/cache:       1128      63329
Swap:         9998         35       9963

The memory has correctly been released and the cache is almost empty!