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

时间:2015-01-27 07:02:29

标签: linux caching memory

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

释放pagecache:

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中是否包含缓冲区缓存?

如果没有,那么是否有一种只释放缓冲区缓存的方法,让页面缓存仍然缓存?

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

1 个答案:

答案 0 :(得分:0)

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.
相关问题