/proc/meminfo detailed

Source: Internet
Author: User

Cat/proc/meminfo read out the kernel information to explain,

The next article will simply analyze the code that reads the information.

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


The corresponding options Chinese meaning thought everyone master already know, how to translate what error, please be sure to point out:

Memtotal: All available RAM sizes (that is, physical memory minus some reserved bits and the kernel's binary code size)

The sum of Memfree:lowfree and Highfree is left unused memory by the system.

Buffers: Used to buffer the file size

Cached: The size of the memory used by the cache memory (equal to DiskCache minus SwapCache).

Swapcached: The size of the swap space used by the cache memory

The memory has been swapped out, but is still stored in the swapfile. Used to quickly be replaced when needed without having to open the I/O port again.

Active: The size of the buffer or buffer memory paging file in active use, unless it is necessary to be removed for his use.

Inactive: The size of the paging file in infrequently used buffers or cache memory may be used in other ways.

Hightotal:

Highfree: The zone is not mapped directly to the kernel space. The kernel must use this memory in a different manner.

Lowtotal:

Lowfree: Low can achieve the same effect as high memory, and it can be used by the kernel to record some of its own data structures. Among many

Other things, it's where everything from the Slab are

Allocated. Bad things happen if you ' re out of Lowmem.

Swaptotal: Total size of swap space

Swapfree: Size of swap space not used

Dirty: The amount of memory waiting to be written back to disk.

Writeback: The amount of memory that is being written back to disk.

Anonpages: Memory size of unmapped pages

Mapped: Size of mappings such as devices and files.

Slab: The size of the kernel data structure cache can reduce the consumption of application and release memory.

Sreclaimable: recoverable slab size

Sunreclaim: Size of Slab not recoverable (Sunreclaim+sreclaimable=slab)

Pagetables: The size of the index table that manages the paging page of memory.

Nfs_unstable: The size of an unstable page table

Bounce:

Commitlimit:based on the overcommit ratio (' vm.overcommit_ratio '),

This was the total amount of memory currently available to

Be allocated on the system. This limit was 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, in a system with 1G of physical RAM and 7G

of swap with a ' vm.overcommit_ratio ' of the 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

had been allocated by processes, even if it had not been

"Used" by them as of yet. A process which malloc () ' s 1G

of memory, but only touches 300M of it would only show up

As using 300M of memory even if it has the address space

Allocated for the entire 1G. This 1G was memory which has

Been "committed" to by the VM and can is 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) won't be permitted. This is useful if one needs

To guarantee that processes won't fail due to lack of

Memory once that memory has been successfully allocated.

Vmalloctotal: Can vmalloc virtual memory size

Vmallocused: The size of the virtual memory that has been used.

Vmallocchunk:largest contigious block of Vmalloc area which are free

Here's a simple example of how the memory and physical memory sizes are used:

#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;

}

Results: Used 488m/total 495M

/proc/meminfo detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.