The biggest advantage of Linux OS is maintaining cache for file-systems, memory pages etc to speedup the cpu process reducing the hard disk i/o. From 2.6.16 kernel a new mechanism has been introduced to have the kernel drop the pagecache, dentries or inodes cache which helps the administrator to throw away that script that allocated a ton of memory just to get rid of the cache.
Its a good practice to run ” sync ” command before using the below options which will sync the RAM cache back to the hard drives.
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
You will see a sudden drop in the ram memory usage after running this commands. Use either top or free -m command to check the memory usage.