Linux usually uses its RAM the smartest way it can. It uses the memory first the makes cache for the recurring requests. Whenever any app needs memory the cache is freed up for that. However if you specifically need to free up the linux cache memory here are some tips. I found them working good.
To free pagecache:
- echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
- echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
- echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are not freeable, the user should run “sync” first in order to make sure all cached objects are freed.
This tunable was added in 2.6.16.
Thanks to LinuxInsight