【问题标题】:How to only free buffer cache in Linux如何在 Linux 中只释放缓冲区缓存
【发布时间】:2015-03-25 17:49:20
【问题描述】:

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

释放页面缓存:

echo 1 > /proc/sys/vm/drop_caches

释放dentries和inode:

echo 2 > /proc/sys/vm/drop_caches

释放 pagecache、dentries 和 inode:

echo 3 > /proc/sys/vm/drop_caches 

我的问题:

缓冲区缓存是否包含在 drop_caches 中?

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

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

【问题讨论】:

    标签: linux caching memory


    【解决方案1】:
    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.
    

    【讨论】:

    • 但我的问题是如何仅释放缓冲区缓存,而不释放页面缓存。你能解释一下缓冲区缓存和页面缓存吗?
    猜你喜欢
    • 1970-01-01
    • 2011-09-01
    • 2021-12-14
    • 1970-01-01
    • 2017-07-27
    • 2022-12-15
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    相关资源
    最近更新 更多