Since kernel 2.6.16, a utility has been provided to allow the system to drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory.
To use /proc/sys/vm/drop_caches, just echo a number to it.
To free pagecache:
1 2 3 |
# echo 1 > /proc/sys/vm/drop_cacheshe |
To free dentries and inodes:
1 2 3 |
# echo 2 > /proc/sys/vm/drop_caches |
To free pagecache, dentries and inodes:
1 2 3 |
# echo 3 > /proc/sys/vm/drop_caches |
This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable.
To free more memory, use the command “sync” command flush them out to disk first.
Example:
1 2 3 |
# sync; echo 3 > /proc/sys/vm/drop_caches |