CAT/proc/meminfo The read kernel information is interpreted,The next article will analyze the code for reading this 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 |
You already know the Chinese meaning and ideology of the corresponding options. Please note:
Memtotal: The size of all available RAM (that is, the physical memory minus some reserved bits and the binary code size of the kernel)
Memfree: Sum of lowfree and highfree, reserved 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)MinusSwapcache ).
Swapcached: The size of swap space used by cache memory
The swap memory is still stored in swapfile. It is used to quickly Replace the I/O port as needed without opening the I/O port again.
Active: The size of page files in active or high-speed buffer memory, which will not be moved for other purposes unless necessary.
Inactive: The size of page files in infrequently used buffer or high-speed buffer storage, which may be used in other ways.
Hightotal:
Highfree: this region is not directly mapped to the kernel space. The kernel must use the memory in different ways.
Lowtotal:
Lowfree: the low level can achieve the same effect as the high memory, and it can also be used by the kernel to record some of its own data structures. Among Networks
Other things, it is where everything from the slab is
Allocated.Bad things happen when you're out oflowmem.
Swaptotal: the total size of swap space.
Swapfree: The size of swap space not used
Dirty: the size of the memory to be written back to the disk.
Writeback: the memory size that is being written back to the disk.
Anonpages: memory size of unmapped pages
Mapped: The ing size of devices and files.
Slab: the size of the kernel data structure cache, which can reduce the consumption caused by memory application and release.
Sreclaimable: the slab size is recoverable.
Sunreclaim: The size of slab that cannot be withdrawn (sunreclaim + sreclaimable = slab)
Pagetables: Manage the size of the index table on the memory paging page.
Nfs_unstable: the size of the unstable page table.
Bounce:
Commitlimit: Based onthe overcommit ratio ('vm. overcommit_ratio '),
This is the total amountMemory currentlyavailable
Be allocated on the system. This limit is only adhered
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 wowould
Yield a commitlimit of 7.3g.
For more details, see the memory overcommit documentation
In VM/overcommit-accounting.
Committed_as: The amount of memorypresently 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 300 m of it will only show up
As using 300 m 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 wowould 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
Memory once that memory has been successfully allocated.
Vmalloctotal: vmalloc virtual memory size
Vmallocused: the virtual memory size used.
Vmallocchunk: largest contigious blockof vmalloc area which is free
Let's take a simple example to see the memory in use and the physical memory size ..
# 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)
{
Charsstatbuf [256];
File * FP;
Int flag;
Int totalmem;
Int usef8;
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 ,"");
Usef8 = atoi (line );
Memset (sstatbuf, 0,256 );
Sprintf (sstatbuf, "used % DM/Total % DM \ n", usef8, totalmem );
If (strlen (sstatbuf)> Len)
{
Return-1;
}
Memcpy (Info, sstatbuf, strlen (sstatbuf ));
Return 0;
}
Result: used 488 M/total 495 m