分享

linux 空闲内存计算 /proc/meminfo文件分析

 点点阅 2017-08-10
2017年7月23日 22:35:44 LINUX系统 & Linux知识 作者 :书生

查看linux系统的内存使用情况,查看文件 cat /proc/meminfo 文件   如果文件里面存在MemAvailable 字段使用它来计算可用内存,如果不存在 使用MemFree字段来计算内存。

MemAvailable是linux 3.14 版本后   在/proc/meminfo文件中新增了一个选项。

MemAvailable的意义如下:
Many load balancing and workload placing programs check /proc/meminfo to
 estimate how much free memory is available. They generally do this by 
adding up "free" and "cached", which was fine ten years ago, but is 
pretty much guaranteed to be wrong today.
It is wrong because Cached includes memory that is not freeable as page 
cache, for example shared memory segments, tmpfs, and ramfs, and it does
 not include reclaimable slab memory, which can take up a large fraction
 of system memory on mostly idle systems with lots of files.Currently, 
the amount of memory that is available for a new workload,without 
pushing the system into swap, can be estimated from MemFree, 
Active(file), Inactive(file), and SReclaimable, as well as the 
"low"watermarks from /proc/zoneinfo.However, this may change in the 
future, and user space really should not be expected to know kernel 
internals to come up with an estimate for the amount of free memory.It 
is more convenient to provide such an estimate in /proc/meminfo. If 
things change in the future, we only have to change it in one place

/proc/meminfo 文件解释

cat /proc/meminfo    读出的内核信息进行解释,

# cat /proc/meminfo
MemTotal:     16438852 kB
MemFree:      10980184 kB
MemAvailable: 11000184 kB
Buffers:         95884 kB
Cached:         224108 kB
SwapCached:          0 kB
Active:        5161616 kB
Inactive:       217660 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:     16438852 kB
LowFree:      10980184 kB
SwapTotal:     1048536 kB
SwapFree:      1048536 kB
Dirty:             424 kB
Writeback:           0 kB
AnonPages:     5059312 kB
Mapped:          20424 kB
Slab:            38176 kB
PageTables:      13480 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   9267960 kB
Committed_AS: 10073960 kB
VmallocTotal: 34359738367 kB
VmallocUsed:    263672 kB
VmallocChunk: 34359473751 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB

字段解释:

MemTotal: 所有可用RAM大小 (即物理内存减去一些预留位和内核的二进制代码大小) 

MemFree: LowFree与HighFree的总和,被系统留着未使用的内存 

Buffers: 用来给文件做缓冲大小 

Cached: 被高速缓冲存储器(cache memory)用的内存的大小(等于 diskcache minus SwapCache ). 

SwapCached:被高速缓冲存储器(cache memory)用的交换空间的大小 已经被交换出来的内存,但仍然被存放在swapfile中。用来在需要的时候很快的被替换而不需要再次打开I/O端口。 

Active: 在活跃使用中的缓冲或高速缓冲存储器页面文件的大小,除非非常必要否则不会被移作他用. 

Inactive: 在不经常使用中的缓冲或高速缓冲存储器页面文件的大小,可能被用于其他途径. 

HighTotal: 
HighFree: 该区域不是直接映射到内核空间。内核必须使用不同的手法使用该段内存。 

LowTotal: 
LowFree: 低位可以达到高位内存一样的作用,而且它还能够被内核用来记录一些自己的数据结构。Among many 
              other things, it is where everything from the Slab is 
              allocated.  Bad things happen when you're out of lowmem. 
          
SwapTotal: 交换空间的总大小 

SwapFree: 未被使用交换空间的大小 

Dirty: 等待被写回到磁盘的内存大小。 
      
Writeback: 正在被写回到磁盘的内存大小。 
   
AnonPages:未映射页的内存大小 
   
Mapped: 设备和文件等映射的大小。 
   
Slab: 内核数据结构缓存的大小,可以减少申请和释放内存带来的消耗。 

SReclaimable:可收回Slab的大小 
   
SUnreclaim:不可收回Slab的大小(SUnreclaim+SReclaimable=Slab) 
   
PageTables:管理内存分页页面的索引表的大小。 
   
NFS_Unstable:不稳定页表的大小 

VmallocTotal: 可以vmalloc虚拟内存大小 

VmallocUsed: 已经被使用的虚拟内存大小。 

VmallocChunk: largest contigious block of vmalloc area which is free


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多