All things are difficult before they are easy. 没有软件的裸机是一具僵尸,没有硬件的软件是一个幽灵。2012,专注于Linux和C语言,关注自动化、性能测试,关注开源社区和开源测试工具、方法,尝试测试团队管理!

Linux free命令详解

上一篇 / 下一篇  2010-11-14 13:17:46 / 个人分类:Linux

查看Linux服务器内存,我们常用的一个命令——free,尽管很常用,但是free命令展示的内容,很多人并非都真的清楚。
首先看一下manual中的说明吧,"free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.  The shared memory column should be ignored; it is obsolete."
然后,我们对free命令展示出来的结果,进行详细的说明吧。
[admin@intlqa142055x ~]$ free
             total       used       free     shared    buffers     cached
Mem:       5120132    5103960      16172          0       2756     285332
-/+ buffers/cache:    4815872     304260
Swap:      2096440    1256072     840368
其中第一行用全局角度描述系统使用的内存状况:
total——总物理内存
used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存
free——完全未被使用的内存
shared——应用程序共享内存
buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)
cached——缓存,用于已打开的文件
note:

total=used+free
used=应用程序使用内存+buffers+cached (maybe add shared also)

第二行描述应用程序的内存使用:
前个值表示-buffers/cache——应用程序使用的内存大小,used减去缓存值
后个值表示+buffers/cache——所有可供应用程序使用的内存大小,free加上缓存值
note:
-buffers/cache=used-buffers-cached
+buffers/cache=free+buffers+cached

第三行表示swap的使用:
used——已使用
free——未使用


如果想要释放cache(当然一般情况下是没有这个必要的):
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
说明,释放前最好sync一下,防止丢数据。

参考资料:http://hi.baidu.com/l269/blog/item/e8cab5cae7c10782c9176887.html


TAG: cache Cache Free free Linux linux 内存

 

评分:0

我来说两句

smile665

smile665

Stay hungry, stay foolish. 得意之时谨记,一半命运还掌握在上帝手里;失意之时须知,一半命运还掌握在自己手里。

日历

« 2024-04-21  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 955303
  • 日志数: 220
  • 建立时间: 2008-11-06
  • 更新时间: 2012-10-06

RSS订阅

Open Toolbar