Linux内存报告差异 [英] Linux memory reporting discrepancy
问题描述
我在meminfo和ps之间发现内存使用差异.与根据ps显然正在使用的进程相比,免费报告的可用内存要少得多.
I'm getting a memory usage discrepancy between meminfo and ps. Free is reporting much less free memory than what processes are apparently using according to ps.
根据免费,我只有3188mb的免费空间:
According to free, I have only 3188mb free:
free -m
total used free shared buffers cached
Mem: 15360 13273 2086 0 79 1022
-/+ buffers/cache: 12171 3188
Swap: 0 0 0
我尝试使用ps(在非0 RSS值下方截取)跟踪内存的位置:
I try to track down where the memory is going using ps (snipped below non 0 RSS values):
ps -A --sort -rss -o comm,pmem,rss
COMMAND %MEM RSS
mysqld 13.1 2062272
java 6.2 978072
ruby 0.7 114248
ruby 0.7 114144
squid 0.1 30716
ruby 0.0 11868
apache2 0.0 10132
apache2 0.0 9092
apache2 0.0 8504
PassengerHelper 0.0 5784
sshd 0.0 3008
apache2 0.0 2420
apache2 0.0 2228
bash 0.0 2120
sshd 0.0 1708
rsyslogd 0.0 1164
PassengerLoggin 0.0 880
ps 0.0 844
dbus-daemon 0.0 736
sshd 0.0 736
ntpd 0.0 664
squid 0.0 584
cron 0.0 532
ntpd 0.0 512
exim4 0.0 504
nrpe 0.0 496
PassengerWatchd 0.0 416
dhclient3 0.0 344
mysqld_safe 0.0 316
unlinkd 0.0 284
logger 0.0 252
init 0.0 200
getty 0.0 120
但是,这没有道理,因为将RSS列加起来会导致总内存使用量仅为 3287mb ,应该几乎有 12gb 的可用空间!
However, this doesn't make sense as adding up the RSS column leads to a total memory usage of only around 3287mb that should leave almost 12gb free!
我在Amazon AWS上使用内核2.6.16.33-xenU#2 SMP x86_64.
I'm using kernel 2.6.16.33-xenU #2 SMP x86_64 on Amazon AWS.
我的记忆要去哪里?谁能阐明如何进行追踪?
Where is my memory going? Can anyone shed some light on how to track this down?
推荐答案
检查Slab缓存的使用情况(/proc/meminfo
中的Slab:
,SReclaimable:
和SUnreclaim:
).这是内核内数据结构的高速缓存,与free
报告的页面高速缓存分开.
Check the usage of the Slab cache (Slab:
, SReclaimable:
and SUnreclaim:
in /proc/meminfo
). This is a cache of in-kernel data structures, and is separate from the page cache reported by free
.
如果您可以在大部分丢失的内存"中使用平板缓存,请检查/proc/slabinfo
以查看丢失的位置.如果是牙科或inode,则可以使用sync ; echo 2 > /proc/sys/vm/drop_caches
摆脱它们.
If the slab cache is resposible for a large portion of your "missing memory", check /proc/slabinfo
to see where it's gone. If it's dentries or inodes, you can use sync ; echo 2 > /proc/sys/vm/drop_caches
to get rid of them.
您还可以使用slabtop
工具以友好格式显示Slab缓存的当前使用情况. c
将按当前缓存大小对列表进行排序.
You can also use the slabtop
tool to show the current usage of the Slab cache in a friendly format. c
will sort the list by current cache size.
这篇关于Linux内存报告差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!