linux cache 内核参数,Linux内核中drop_caches参数
該參數從 Kernels 2.6.16 開始引入,用于調整內核清理緩存的行為,該操作將回收緩存及清理可回收對象。一旦回收完成,該部分內存將變成 free 。
drop_caches 參數共有三個值:
1: 只清理 pagecache
2: 清理可回收對象(包括 dentries 和 inodes)
3: 同時清理 pagecache 和 可回收對象
此操作是非破壞性的操作,不會釋放任何的臟數據。如果需要增加被釋放的對象,需要先運行 sync 操作。
設置此參數可能導致系統性能下降,主要是由于他丟棄了一部分緩存對象,導致頻繁的與磁盤交互進行對象的重建,不建議在測試環境以外使用。
英文摘要:
drop_caches
Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like dentries and inodes. Once dropped, their
memory becomes free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
echo 3 > /proc/sys/vm/drop_caches
This is a non-destructive operation and will not free any dirty objects.
To increase the number of objects freed by this operation, the user may run
`sync’ prior to writing to /proc/sys/vm/drop_caches. This will minimize the
number of dirty objects on the system and create more candidates to be
dropped.
This file is not a means to control the growth of the various kernel caches
(inodes, dentries, pagecache, etc…) These objects are automatically
reclaimed by the kernel when memory is needed elsewhere on the system.
Use of this file can cause performance problems. Since it discards cached
objects, it may cost a significant amount of I/O and CPU to recreate the
dropped objects, especially if they were under heavy use. Because of this,
use outside of a testing or debugging environment is not recommended.
You may see informational messages in your kernel log when this file is
used:
cat (1234): drop_caches: 3
These are informational only. They do not mean that anything is wrong
with your system. To disable them, echo 4 (bit 2) into drop_caches.
總結
以上是生活随笔為你收集整理的linux cache 内核参数,Linux内核中drop_caches参数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux删除物理卷命令,如何安全的删除
- 下一篇: linux 同步 多终端,Linux系统