gpt4 book ai didi

linux - 如何在 Linux 中只释放缓冲区缓存

转载 作者:太空宇宙 更新时间:2023-11-04 05:28:04 24 4
gpt4 key购买 nike

我知道Linux中有页缓存和缓冲区缓存。页缓存用于文件系统,缓冲区缓存用于设备。

释放页面缓存:

echo 1 > /proc/sys/vm/drop_caches

释放 dentry 和 inode:

echo 2 > /proc/sys/vm/drop_caches

释放页面缓存、目录项和 inode :

echo 3 > /proc/sys/vm/drop_caches 

我的问题:

drop_caches 是否覆盖了缓冲区缓存?

如果没有,那么有没有一种方法可以只释放缓冲区缓存,而使页面缓存仍然被缓存?

如果没有,为什么没有必要或不可能?

最佳答案

Ans:-    

sync; echo 3 > /proc/sys/vm/drop_caches

Here’s the output of free before and after running the above command.

Before

# free -m
total used free shared buffers cached
Mem: 502 487 15 0 15 170
-/+ buffers/cache: 301 201
Swap: 3153 375 2777
After

# free -m
total used free shared buffers cached
Mem: 502 345 157 0 1 44
-/+ buffers/cache: 300 202
As you can see the highlighted numbers, the buffers and cached values have dropped significantly after I ran the command. Again, this is not necessary. In fact, it’s not recommended at all but there it is if you’re curious to know.

关于linux - 如何在 Linux 中只释放缓冲区缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28164971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com