linux flushing file system caches

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

上一篇:有关mysql的innodb_flush_log_at_trx_commit参数


下一篇:Hbase性能调优(二)