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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值