linux的内存使用查看和实际可用内存计算

使用free,top等工具都可以查看linux的内存使用量,如
使用top命令

bear@njava:/etc/nginx/conf# top
Tasks:  36 total,   2 running,  32 sleeping,   2 stopped,   0 zombie
Cpu(s):  0.3%us,  0.3%sy,  0.0%ni, 99.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    524800k total,   478320k used,    46480k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
15658 www-data  23   0 49188 7280 4104 S  0.0  1.4   0:00.03 php5-cgi           
15663 www-data  16   0 57888  28m  16m S  0.0  5.5   0:12.62 php5-cgi           
15664 www-data  16   0 60704  32m  18m S  0.0  6.4   0:11.99 php5-cgi           
15665 www-data  16   0 59488  29m  16m S  0.0  5.8   0:11.00 php5-cgi           
15667 www-data  18   0 58388  30m  17m S  0.0  5.9   0:11.62 php5-cgi           
15668 www-data  16   0 58628  28m  16m S  0.0  5.6   0:12.05 php5-cgi           
15669 www-data  16   0 58660  29m  16m S  0.0  5.7   0:09.81 php5-cgi           
15670 www-data  16   0 56220  26m  16m S  0.0  5.2   0:11.24 php5-cgi           
15671 www-data  16   0 59432  29m  16m S  0.0  5.8   0:11.04 php5-cgi           
15673 www-data  16   0 54596  25m  16m S  0.0  4.9   0:12.43 php5-cgi           
15674 www-data  16   0 58036  27m  15m S  0.0  5.4   0:11.66 php5-cgi           
19790 www-data  15   0 10856 2644 1008 S  0.0  0.5   0:02.18 nginx              
19791 www-data  18   0 10856 2676 1060 S  0.0  0.5   0:01.55 nginx              
19939 www-data  17   0  6936 3136  744 S  0.0  0.6   0:00.11 nginx-fcgi 

使用free命令

bear@njava:/etc/nginx/conf# free
             total       used       free     shared    buffers     cached
Mem:        524800     476756      48044          0          0          0
-/+ buffers/cache:     476756      48044
Swap:            0          0          0
bear@njava:/etc/nginx/conf# 

又那么多的内存参数字段:used,free,shared,buffers,cached
怎么计算实际剩余可用内存呢?
公式如下:

空闲内存=free+buffers+cached

看上去巴士的vps不适合做这个例子,呵呵,当作留存吧

Tags: ,

星期五, 2 4 月, 2010 服务器

Leave a Reply

1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr