Linux free显示高内存使用率,但top却没有 [英] Linux free shows high memory usage but top does not

查看:3331
本文介绍了Linux free显示高内存使用率,但top却没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在RedHat Linux 6.2上,我正在运行free -m,它显示几乎所有已使用的8GB

On RedHat Linux 6.2 I'm running free -m and it shows nearly all 8GB used

             total       used       free     shared    buffers     cached
Mem:          7989       7734        254          0         28       7128
-/+ buffers/cache:        578       7411
Swap:         4150          0       4150

但是同时在top -M中,我看不到使用所有这些内存的任何进程:

But at the same time in top -M I cannot see any processes using all this memory:

top - 16:03:34 up  4:10,  2 users,  load average: 0.08, 0.04, 0.01
Tasks: 169 total,   1 running, 163 sleeping,   5 stopped,   0 zombie
Cpu(s):  0.7%us,  0.3%sy,  0.0%ni, 98.6%id,  0.4%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  7989.539M total, 7721.570M used,  267.969M free,   28.633M buffers
Swap: 4150.992M total,    0.000k used, 4150.992M free, 7115.312M cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1863 sroot     20   0  398m  24m 9.8m S  0.3  0.3   3:12.87 App1
    1 sroot     20   0  2864 1392 1180 S  0.0  0.0   0:00.91 init
    2 sroot     20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 sroot     RT   0     0    0    0 S  0.0  0.0   0:00.07 migration/0
    4 sroot     20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    5 sroot     RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    6 sroot     RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    7 sroot     RT   0     0    0    0 S  0.0  0.0   0:00.08 migration/1
    8 sroot     RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1

我也尝试过 ps mem脚本,但是它显示大约使用了400MB内存.

I also tried this ps mem script but it onlt shows about 400MB memory being used.

推荐答案

不要看"Mem"行,而是看它下面的那一行.

Don't look at the "Mem" line, look at the one below it.

Linux内核会消耗尽可能多的内存来提供I/O缓存(以及其他非关键缓冲区,但是缓存将是这种用法的大部分).当进程请求该内存时,将其释放给它们. -/+缓冲区/高速缓存"行向您显示在考虑了I/O高速缓存之后的调整值,即进程使用的内存量和进程可用的容量(在这种情况下,已使用578MB, 7411MB免费).

The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free).

"Mem"和-/+缓冲区/高速缓存"行之间已用内存的差异向您显示内核为高速缓存使用的内存量:I/O高速缓存中的7734MB-578MB = 7156MB .如果进程需要此内存,则内核将简单地缩小I/O缓存的大小.

The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.

这篇关于Linux free显示高内存使用率,但top却没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆