下篇对cat /proc/meminfo读出该信息进行简单的分析。

MemTotal: 507480 kB
MemFree: 10800 kB
Buffers: 34728 kB
Cached: 98852 kB
SwapCached: 128 kB
Active: 304248 kB
Inactive: 46192 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 507480 kB
LowFree: 10800 kB
SwapTotal: 979956 kB
SwapFree: 941296 kB
Dirty: 32 kB
Writeback: 0 kB
AnonPages: 216756 kB
Mapped: 77560 kB
Slab: 22952 kB
SReclaimable: 15512 kB
SUnreclaim: 7440 kB
PageTables: 2640 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 1233696 kB
Committed_AS: 828508 kB
VmallocTotal: 516088 kB
VmallocUsed: 5032 kB
VmallocChunk: 510580 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: 正在被写回到磁盘的内存大小。
Mapped: 设备和文件等映射的大小。
Slab: 内核数据结构缓存的大小,可以减少申请和释放内存带来的消耗。
SReclaimable:可收回Slab的大小
SUnreclaim:不可收回Slab的大小(SUnreclaim+SReclaimable=Slab)
PageTables:管理内存分页页面的索引表的大小。
NFS_Unstable:不稳定页表的大小
Bounce:

CommitLimit: 
Based on the overcommit ratio('vm.overcommit_ratio'),this is the total amount of  memory currently available to be allocated on the system. This limit is only adhered to if strict overcommit accounting is enabled (mode 2 in 'vm.overcommit_memory').
The CommitLimit is calculated with the following formula:
CommitLimit = ('vm.overcommit_ratio' * Physical RAM) + Swap
For example, on a system with 1G of physical RAM and 7G of swap with a `vm.overcommit_ratio` of 30 it would yield a CommitLimit of 7.3G.
For more details, see the memory overcommit documentation in vm/overcommit-accounting.

Committed_AS: 
The amount of memory presently allocated on the system.
The committed memory is a sum of all of the memory which has been allocated by processes, even if it has not been "used" by them as of yet. A process which malloc()'s 1G of memory, but only touches 300M of it will only show up as using 300M of memory even if it has the address space allocated for the entire 1G. This 1G is memory which has been "committed" to by the VM and can be used at any time by the allocating application. With strict overcommit enabled on the system (mode 2 in 'vm.overcommit_memory'), allocations which would exceed the CommitLimit (detailed above) will not be permitted. This is useful if one needs to guarantee that processes will not fail due to lack of memory once that memory has been successfully allocated.

VmallocTotal: 可以vmalloc虚拟内存大小
VmallocUsed: 已经被使用的虚拟内存大小。
VmallocChunk: largest contigious block of vmalloc area which is free

下面简单来个例子,看看已用内存和物理内存大小.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int MemInfo(char* Info, int len);
int main()
{char buf[128];memset(buf, 0, 128);MemInfo(buf, 100);printf("%s", buf);return 0;
}
int MemInfo(char* Info, int len)
{char sStatBuf[256];FILE* fp;int flag;int TotalMem;int UsedMem;char* line;if(system("free -m | awk '{print $2,$3}' > mem"));memset(sStatBuf, 0, 256);fp = fopen("mem", "rb");if(fp < 0){return -1;}fread(sStatBuf,1, sizeof(sStatBuf) , fp);line = strstr(sStatBuf, "\n");TotalMem = atoi(line);line = strstr(line, " ");UsedMem = atoi(line);memset(sStatBuf, 0, 256);sprintf(sStatBuf, "Used %dM/Total %dM\n", UsedMem, TotalMem);if(strlen(sStatBuf) > len){return -1;}memcpy(Info, sStatBuf, strlen(sStatBuf));return 0;
}
结果:Used 488M/Total 495M

linux meminfo详解相关推荐

  1. /proc/meminfo详解 = /nmon analysis --MEM

    memtotal hightotal lowtotal swaptotal memfree highfree lowfree swapfree memshared cached active bigf ...

  2. linux /proc 详解

    linux /proc 详解 本文整理了一下 linux /proc下的几个常用的目录和文件,可供查阅,之后在学习工作中有别的用到的话会再补充. /proc 简介 Linux系统上的/proc目录是一 ...

  3. Linux 目录详解 树状目录结构图

    1.树状目录结构图 2./目录 目录 描述 / 第一层次结构的根.整个文件系统层次结构的根目录. /bin/ 需要在单用户模式可用的必要命令(可执行文件):面向所有用户,例如:cat.ls.cp,和/ ...

  4. Linux proc详解

    本文转自:http://hi.baidu.com/beyond907/blog/item/250f41249c9fbb7435a80fd2.html Linux procfs详解 1.0 proc文件 ...

  5. 《Linux命令详解手册》——Linux畅销书作家又一力作

    关注IT,更要关心IT人,让系统管理员以及程序员工作得更加轻松和快乐.鉴于此, 图灵公司引进了国外知名出版社John Wiley and Sons出版的Fedora Linux Toolbox: 10 ...

  6. Linux系统详解 系统的启动、登录、注销与开关机

    Linux系统详解 第六篇:系统的启动.登录.注销与开关机 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://johncai.blo ...

  7. 每天一个linux命令(25):linux文件属性详解

    每天一个linux命令(25):linux文件属性详解 Linux 文件或目录的属性主要包括:文件或目录的节点.种类.权限模式.链接数量.所归属的用户和用户组.最近访问或修改的时间等内容.具体情况如下 ...

  8. c linux time微秒_学习linux,看这篇1.5w多字的linux命令详解(6小时讲明白Linux)

    用心分享,共同成长 没有什么比每天进步一点点更重要了 本篇文章主要讲解了一些linux常用命令,主要讲解模式是,命令介绍.命令参数格式.命令参数.命令常用参数示例.由于linux命令较多,我还特意选了 ...

  9. Linux系统结构 详解

    Linux系统结构 详解 标签: 产品产品设计googleapple互联网 2011-01-07 14:14 31038人阅读 评论(6) 收藏 举报 分类: Linux(21) 版权声明:本文为博主 ...

最新文章

  1. linux 防火墙 -netfilter
  2. PostProcessor
  3. 春风十里不如春城一聚:华平解决方案巡展走进昆明
  4. Dell XP版本在非Dell机子上的激活问题
  5. 许多参数和丢失的信息
  6. Nginx学习之一-第一个程序Hello World
  7. python备份虚拟环境
  8. 文件一另存为电脑就卡住_文件太多怎么办?用Excel做一个简易目录!轻松管理多个文件...
  9. git远程删除分支后,本地git branch -a 依然能看到的解决办法
  10. Android开发的第一天
  11. mysql多表连接的几种写法
  12. java 注解处理器的作用_JVM进阶 -- 浅谈注解处理器
  13. 10款超好用插件,助你玩转Chrome浏览器
  14. vga是计算机的什么接口,VGA/DVI/HDMI三种接口有什么区别?
  15. 成考计算机专业难不难,成人高考计算机专业难吗?
  16. jmeter里看java的log,jmeter中java协议请求
  17. 上手 WebRTC DTLS 遇到很多 BUG,怎么解?
  18. 机器视觉——相机选型
  19. 2B青年答疑:什么是2B青年?如何脱离2B青年行列?
  20. 计算机系统自动撮合成交的原则,【期货小讲堂】你知道价格优先、时间优先撮合原则嘛?...

热门文章

  1. 双显卡笔记本安装win10+Ubuntu16.04以及NVIDIA显卡驱动安装
  2. 小米4硬改教程_用小米手环让Windows免密成为日常~
  3. iOS直播研发初了解
  4. JBPM6 学习(一)---JBPM6使用Oracle11g实现
  5. 绢丝的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
  6. 微服务架构下得分布式事务解决方案
  7. 我的硬汉观——《丧钟为谁而鸣》读书感悟
  8. Chapter002[SAS DATA步之全解密-01]
  9. win10 驱动无法安装 系统找不到指定文件
  10. Jenkins + fastlane