[20160902]简单探究linux的free命令.txt

[20160902]linux命令free的buffers与cached表示什么.txt

--简单探究linux的free命令。
$ free
             total       used       free     shared    buffers     cached
Mem:     132261196   29620656  102640540          0     174340   24209712
-/+ buffers/cache:    5236604  127024592
Swap:     31455264      10592   31444672

-/+ buffers/cache的used: used - buffers - cached
                         29620656- 174340-24209712=5236604
-/+ buffers/cache的free: free + buffers + cached       
                         102640540+ 174340+24209712=127024592

--而buffers和cached表示什么呢?
下面是关于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 memory很少,不用担心,用来缓存文件了,另外可以如下命令来释放相关内存。

--To free pagecache:
# echo 2 >| /proc/sys/vm/drop_caches

$ free
             total       used       free     shared    buffers     cached
Mem:     132261196    7420620  124840576          0     174368    2662916
-/+ buffers/cache:    4583336  127677860
Swap:     31455264      10592   31444672

--//你可以对比上面buffers几乎不变。而cached减少了不少。

--To free dentries and inodes:
# echo 1 >| /proc/sys/vm/drop_caches
# free
             total       used       free     shared    buffers     cached
Mem:     132261196    6709548  125551648          0       1008    2228344
-/+ buffers/cache:    4480196  127781000
Swap:     31455264      10592   31444672

--//对比上面buffers减少很多,cached几乎不变,再次验证文档的内容。如果执行
--# To free pagecache, dentries and inodes:
--# echo 3 >| /proc/sys/vm/drop_caches
--这个测试大家可以自己测试。

--可以在反向验证这个判断。
# cd /
# ls -lR > /dev/null

--然后打开另外的窗口观察:
# free
             total       used       free     shared    buffers     cached
Mem:     132261196    6798588  125462608          0      15512    2232348
-/+ buffers/cache:    4550728  127710468
Swap:     31455264      10592   31444672
# sleep 5
# free
             total       used       free     shared    buffers     cached
Mem:     132261196    6969776  125291420          0      66568    2232716
-/+ buffers/cache:    4670492  127590704
Swap:     31455264      10592   31444672

# sleep 5
# free
             total       used       free     shared    buffers     cached
Mem:     132261196    7347624  124913572          0     117412    2458840
-/+ buffers/cache:    4771372  127489824
Swap:     31455264      10592   31444672

--增加主要的是buffers,也就是缓存用户目录、inode值等。希望通过这个简单的测试理解linux命令free的内容。

时间: 2024-07-29 11:50:57

[20160902]简单探究linux的free命令.txt的相关文章

[20170315]简单探究dg的mrp进程.txt

[20170315]简单探究dg的mrp进程.txt --//昨天上午在做测试做在线日志与备用日志大小不一样时遇到一个令我困惑的问题,链接: http://blog.itpub.net/267265/viewspace-2135377/ --//发现mrp进程并没有打开数据文件的句柄.这样MRP进程如何应用日志的呢?简单探究看看: 1.环境: SYS@192.168.31.8/xxxxxx> @ &r/ver1 PORT_STRING                    VERSION  

[20121121]关于linux下history命令.txt

[20121121]关于linux下history命令.txt 昨天跟别人聊天,提到linux下history命令带来的安全隐患,主要是一些命令会记录在~/.bash_history中.实际上有许多方法可以使系统不记录这样一些命令,自己也看了一些文档,总结如下: 1.使用环境变量HISTCONTROL. export HISTCONTROL=ignorespace 如果设置HISTCONTROL=ignorespace,这样开头有空格的命令就不会记录.例子: export HISTCONTROL

[20120608]linux的kill命令.txt

[20120608]linux的kill命令.txt 在我开始学习linux的时候,在学习kill命令杀进程的时候,要杀掉进程应该使用kill -9才行,昨天看了文档,学习了一些kill的语法:kill -l 可以显示signal. # kill -l  1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL  5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE  9) S

[20120612]linux的cloumn命令.txt

昨天看别人操作linux,发现column的一个用法: # mount /dev/sda3 on / type ext3 (rw) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) usbfs on /proc/bus/usb type usbfs (rw) /dev/sda2 on /boot type ext3 (rw) none

[20140114]简单探究nested table-之2.txt

  [20140114]简单探究nested table-存储问题.txt 对nested table一点也不熟悉,估计也很少人使用,今天看了一些文档,做一些简单的探究,估计以后也不会使用. 1.测试环境: SCOTT@test> @ver BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Re

[20170705]理解linux su命令.txt

[20170705]理解linux su命令.txt --//我一般在维护时经常使用root用户登录,然后su - oracle 转到其他用户操作 --//一般都加入 - 参数.这个已经成了条件反射...^_^. # man su       Change the effective user id and group id to that of USER. -, -l, --login make the shell a login shell --//也就是使用login里面的shell,设置

[20171109]简单探究文件ab_ASM_SID.dat.txt

[20171109]简单探究文件ab_ASM_SID.dat.txt --//昨天看了一篇Solving Communication problems between DB and ASM instances.链接 --//http://www.toadworld.com/platforms/oracle/b/weblog/archive/2017/11/07/solving-communication-problems-between-db-and-asm-instances --//如果意外

[20170910]imp参数buffer的简单探究2.txt

[20170910]imp参数buffer的简单探究2.txt --//exp,imp已经很少在用,如果存在8i估计还会用一下,下面因为别人遇到升级忘记家buffer参数(8i),导致导入缓慢, --//当然还有许多因素,比如存在lob字段,不过还是简单探究参数buffer. --//上个星期做了参数buffer的简单探究,发现缓存大小除以记录的最大长度=每次插入记录数量. --//忘记测试缺省是多少,补充测试看看. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRI

[20170908]imp参数buffer的简单探究.txt

[20170908]imp参数buffer的简单探究.txt --//exp,imp已经很少在用,如果存在8i估计还会用一下,下面因为别人遇到升级忘记家buffer参数(8i),导致导入缓慢, --//当然还有许多因素,比如存在lob字段,不过还是简单探究参数buffer. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER -----------------------------