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

202001111578718531556975.ico摘要:

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

查看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

本文标题:linux 空闲内存计算 /proc/meminfo文件分析

本文链接:https://www.kyjszj.com/wdzl/145.html

作者授权:除特别说明外,本文由 开源技术之家 原创编译并授权 开源技术之家 刊载发布。

版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值