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: 正在被写回到磁盘的内存大小。

AnonPages:未映射页的内存大小

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

/proc/meminfo详解的更多相关文章

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

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

  2. #cat /proc/meminfo 详解

    $cat /proc/meminfoMemTotal:        2052440 kB //总内存MemFree:           50004 kB //空闲内存Buffers:        ...

  3. Android内存优化—dumpsys meminfo详解

    原创置顶 不死鸟JGC 最后发布于2018-12-24 14:19:28 阅读数 3960 收藏展开dumpsys 介绍Dumpsys用户系统诊断,它运行在设备上,并提供系统服务状态信息 命令格式: ...

  4. Linux /proc目录详解

    Linux系统上的/proc目录是一种文件系统,即proc文件系统.与其它常见的文件系统不同的是,/proc是一种伪文件系统(也即虚拟文件系统),存储的是当前内核运行状态的一系列特殊文件,用户可以通过 ...

  5. proc文件系统详解(原创)

    Linux系统上的/proc目录是一种文件系统,即proc文件系统.与其它常见的文件系统不同的是,/proc是一种伪文件系统(也即虚拟文件系统),存储的是当前内核运行状态的一系列特殊文件,用户可以通过 ...

  6. proc文件系统详解

    /proc 文件系统是一个虚拟文件系统,通过它可以使用一种新的方法在 Linux内核空间和用户间之间进行通信.在 /proc 文件系统中,我们可以将对虚拟文件的读写作为与内核中实体进行通信的一种手段, ...

  7. /proc/uptime详解

    From:http://smilejay.com/2012/05/proc_uptime/ 在Linux中,我们常常会使用到uptime命令去看看系统的运行时间,它与一个文件有关,就是/proc/up ...

  8. linux下proc目录详解

    proc/pid记录了什么cd /proc/之后,你会发现很多的目录和文件,今天首先来介绍的就是那些以数字命名的目录--它们就是linux中的进程号,每当你创建一个进程时,里面就会动态更新多出一个名称 ...

  9. /proc/sysrq-trigger详解

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://itnihao.blog.51cto.com/1741976/830374 htt ...

随机推荐

  1. Linux_脚本——使用echo从一个文件写入还有一个文件末尾

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/svitter/article/details/30980923 echo $(cat 你须要的文件) ...

  2. 【转】Android之drawable state各个属性详解

    我们在定义一个drawable的时候可以通过xml定义的drawable对象.它使得一个图片能在不同的状态下显示不同的图案,比如一个Button,它有pressed,focused,或者其它状态,通过 ...

  3. TensorFlow基础(二)实现神经网络

    (1)前向传播算法 神经网络的前向传播算法主要构成部分: 1.神经网络的输入: 2.神经网络的连接结构:神经网络是由神经元(节点)构成的 3.每个神经元中的参数. (2)TensorFlow随机数生成 ...

  4. Linux实用指令(1):运行级别&找回密码&帮助指令&文件目录类

    指令运行级别: 0 :关机 1 :单用户[找回丢失密码] 2:多用户状态没有网络服务 3:多用户状态有网络服务 4:系统未使用保留给用户 5:图形界面 6:系统重启   常用运行级别是3和5 ,要修改 ...

  5. [转]MFC子线程更改图像数据后更新主窗口图像显示方法

    程序思路是由外部的输入输出控制卡发出采集图像信号,之后相机采集图像得到图像数据指针,接收图像数据指针创建成图像最后显示到MFC对话框应用程序的Picture Control控件上,同时,为了标定相机位 ...

  6. 二十九、利用 IntelliJ IDEA 进行代码对比的方法

    我们会有这样的需求,即:想对比出两个不同版本代码的区别.如何实现? 第 1 种:如果我们是从 SVN 检出的项目,并且想比较本地代码与从 SVN 检出时的代码相比都有那些区别,可以按如下步骤操作, 如 ...

  7. ARP, Fragmentation and Reassembly

    Address Resolution Protocol IP addresses are said to be logical, because they are defined in terms o ...

  8. 一招搞定css页面布局

    如何做出漂亮的页面: 1. 多写页面,多改. 2. 多写页面,多改. 3. 多写页面,多改. 大致的思想步骤: 写页面的时候先规划好大致的分块,无论是用定位或者浮动,首先要确定要应用的场景,使用完浮动 ...

  9. 系统优化怎么做-Linux系统配置优化

    大家好,这里是「聊聊系统优化 」,并在下列地址同步更新 博客园:http://www.cnblogs.com/changsong/ 知乎专栏:https://zhuanlan.zhihu.com/yo ...

  10. sql1999语法

    1.交叉连接 cross join 左右两个表进行组合,产生笛卡尔积累. 左边每一行分别于右表每一行数据匹配. 2.using using使用的前提是两个表右关联的字段需要对应,两个表的join查询. ...