Linux free 显示内存使用率高,但 top 没有
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17618737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linux free shows high memory usage but top does not
提问by DarVar
On RedHat Linux 6.2 I'm running free -m
and it shows nearly all 8GB
used
在 RedHat Linux 6.2 上我正在运行free -m
,它显示几乎所有8GB
使用过的
total used free shared buffers cached
Mem: 7989 7734 254 0 28 7128
-/+ buffers/cache: 578 7411
Swap: 4150 0 4150
But at the same time in top -M
I cannot see any processes using all this memory:
但与此同时,top -M
我看不到任何使用所有这些内存的进程:
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
I also tried this ps mem scriptbut it onlt shows about 400MB memory being used.
我也试过这个ps mem 脚本,但它只显示正在使用大约 400MB 的内存。
采纳答案by cdhowie
Don't look at the "Mem" line, look at the one below it.
不要看“Mem”行,看看它下面的那一行。
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).
Linux 内核消耗尽可能多的内存来提供 I/O 缓存(和其他非关键缓冲区,但缓存将是这种使用的大部分)。当进程请求它时,该内存被放弃给进程。“-/+ buffers/cache”行显示了考虑 I/O 缓存后的调整值,即进程使用的内存量和进程可用的内存量(在这种情况下,使用了 578MB, 7411MB 免费)。
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.
"Mem" 和 "-/+ buffers/cache" 行之间已用内存的差异显示内核用于缓存的内存量:7734MB - 578MB = 7156MB 在 I/O 缓存中。如果进程需要这个内存,内核将简单地缩小 I/O 缓存的大小。
回答by Gnana
Also, as the first line shows
total used free shared buffers cached
Mem: 7989 7734 254 0 28 7128
-/+ buffers/cache: 578 7411
此外,如第一行所示
total used free shared buffers cached
Mem: 7989 7734 254 0 28 7128
-/+ buffers/cache: 578 7411
If we add (cached[7128] + buffers[28] + free[254]), we will get approximately the second line's free[7411] value7128 + 28 + 254 = 7410
如果我们添加 (cached[7128] + buffers[28] + free[254]),我们将得到大约第二行的 free[7411] 值7128 + 28 + 254 = 7410
回答by xiaolunli
If the cached is small, try this command:
如果缓存很小,试试这个命令:
ps aux --sort -rss