We may drop the file system caches on Linux to free up memory for applications. Kernels 2.6.16 and newer provide a mechanism via the /proc/ to make the kernel drop the page cache and/or inode and dentry caches on command. We can use this mechanism to free up the memory. However, this is a non-destructive operation that only free things that are completely unused and dirty objects will not be freed until written out to disk. Hence, we should flush these dirty objects to disk first. We can run sync to flush them out to disk. And the drop operations by the kernel will free more memory.
We can flush caches of the file systems by two steps:
Flush file system buffers
Call the sync command:
# sync
Free pagecache, dentries and inodes
Just echoing a number to /proc/sys/vm/drop_caches:
# echo 3 > /proc/sys/vm/drop_caches
原文:https://www.cnblogs.com/longchang/p/10767434.html