[20161012]linux free的补充.txt

[20161012]linux free的补充.txt

--前一阵子写的:
http://blog.itpub.net/267265/viewspace-2124363/

下面是关于buffers和cached的英文资料:

Buffers are associated with a specific block device, and cover caching of filesystem metadata as well as tracking
in-flight pages. The cache only contains parked file data. That is, the buffers remember what's in directories, what
file permissions are, and keep track of what memory is being written from or read to for a particular block device. The
cache only contains the contents of the files themselves.

-- buffers 缓存,主要用于块设备缓存,例如用户目录、inode值等(ls大目录可以看到这个值增加)
-- cached  缓存,主要用于缓存文件。

--有一些理解不是很清除.

$ free -m
             total       used       free     shared    buffers     cached
Mem:        129161      19398     109762          0        435       7910
-/+ buffers/cache:      11053     118108
Swap:        30718         10      30707

$ dd if=/dev/zero of=aaaaaaa bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 1.86119 seconds, 563 MB/s

$ free -m
             total       used       free     shared    buffers     cached
Mem:        129161      20412     108748          0        437       8910
-/+ buffers/cache:      11064     118096
Swap:        30718         10      30707

--我建立1个1000M的文件,cached从7910=>8910.buffers几乎不变。

# dd if=/dev/cciss/c0d0p6 of=/dev/null bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 12.1073 seconds, 86.6 MB/s

--注意,我看了一些网站的blog,if与of是写反的,应该也能测试出来。这样你必须保证这个块设备没有内容,总之千万别写反了。

# free -m
             total       used       free     shared    buffers     cached
Mem:        129161      28231     100929          0       8039       8910
-/+ buffers/cache:      11281     117880
Swap:        30718         10      30707

# echo 1 >| /proc/sys/vm/drop_caches
# free -m
             total       used       free     shared    buffers     cached
Mem:        129161      13252     115909          0          0       2277
-/+ buffers/cache:      10973     118187
Swap:        30718         10      30707

--我前一个测试有一些问题实际上echo 1 >| /proc/sys/vm/drop_caches,buffers与cached好像都清除的。不知道为什么?
--有一些概念还不是很清楚。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2126155/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/267265/viewspace-2126155/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值