打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
linux 空闲内存计算 /proc/meminfo文件分析
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/meminfoMemTotal:     16438852 kBMemFree:      10980184 kBMemAvailable: 11000184 kBBuffers:         95884 kBCached:         224108 kBSwapCached:          0 kBActive:        5161616 kBInactive:       217660 kBHighTotal:           0 kBHighFree:            0 kBLowTotal:     16438852 kBLowFree:      10980184 kBSwapTotal:     1048536 kBSwapFree:      1048536 kBDirty:             424 kBWriteback:           0 kBAnonPages:     5059312 kBMapped:          20424 kBSlab:            38176 kBPageTables:      13480 kBNFS_Unstable:        0 kBBounce:              0 kBCommitLimit:   9267960 kBCommitted_AS: 10073960 kBVmallocTotal: 34359738367 kBVmallocUsed:    263672 kBVmallocChunk: 34359473751 kBHugePages_Total:     0HugePages_Free:      0HugePages_Rsvd:      0Hugepagesize:     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


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
linux怎么清除缓存(转)
用 Python 脚本实现对 Linux 服务器的监控
Linux内存使用情况观察
linux下使用free命令查看实际内存占用(可用内存)
Linux中检查内存使用情况的命令
如何检查Linux系统的内存使用量是否耗尽
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服