Detailed explanation of each field of cat /proc/meminfo

Detailed explanation of each field of cat /proc/meminfo

Reference link: https://blog.csdn.net/JustDoIt_201603/article/details/106629059


1. Detailed explanation of each field of cat /proc/meminfo

/ $ cat /proc/meminfo
MemTotal: 877368 kB : All available RAM size (that is, physical memory minus some reserved bits and kernel binary code size) (HighTotal + LowTotal), system from power-on to boot completion, BIOS, etc. To reserve some memory, the kernel must reserve some memory, and the last remaining memory at the disposal of the system is MemTotal. This value is generally fixed during system operation.
MemFree: 22516 kB: The sum of LowFree and HighFree, which is left unused by the system. MemFree refers to the system level
MemAvailable: 470244 kB: The number of available memory for applications. Although some memory in the system has been used, it can be recycled. For example, cache/buffer and slab can all be recycled, so MemFree cannot represent all available memory. This part of recyclable memory plus MemFree is the memory available to the system. That is: MemAvailable≈MemFree+Buffers+Cached, it is calculated by the kernel using a specific algorithm, it is an estimate, MemAvailable refers to the application level
Buffers: 1772 kB: used to buffer files
Cached: 459224 kB: used The size of the memory used by the cache memory (equal to diskcache minus SwapCache)
SwapCached: 16 kB: The size of the swap space used by the cache memory, the memory that has been swapped out, but is still stored in in swapfile. Used to be quickly replaced when needed without opening the I/O port again
Active: 333148 kB : The size of the buffer or cache paging file that is in active use and will not be used for other purposes unless absolutely necessary. (Active(anon) + Active(file)) Inactive: 330384 kB :
Inactive The size of the buffer or cache paging file that is in active use and may be used by other means. (Inactive(anon) + Inactive(file)) Active(anon): 104368 kB : Active memory not associated with files (such as
process stack, memory requested by malloc) (anonymous pages), anonymous pages read/write the swap area when a page change occurs Inactive(
anon): 104508 kB: Inactive memory that has nothing to do with files (such as process stack, memory requested by malloc)
Active(file): 228780 kB: Active memory associated with files (such as memory pages corresponding to program files and data files) (file-backed pages) File-backed pages are changing When a page (page-in or page-out) is read in or written out from its corresponding file
Inactive(file): 225876 kB: Inactive memory associated with the file (such as memory corresponding to program files and data files Pages)
Unevictable: 6708 kB :
Mlocked: 1428 kB :
HighTotal: 261888 kB: The total size of high memory (Highmem refers to all physical memory with memory higher than 860MB. The Highmem area is used by user programs or used for page cache. This area is not directly mapped to kernel space. The kernel must use different methods Use this segment of memory)
HighFree: 5680 kB: the unused high memory size
LowTotal: 615480 kB: the total size of the low memory, the low memory can achieve the same function as the high memory, and it can also be used by the kernel to record some of its own data structures
LowFree: 16836 kB: Unused low-order size
SwapTotal: 614396 kB: Total size of swap space
SwapFree: 611044 kB: Size of unused swap space
Dirty: 40 kB: Memory size waiting to be written back to disk
Writeback: 0 kB: the memory size being written back to disk
AnonPages: 209224 kB: the memory size of unmapped pages
Mapped: 280668 kB: the size of devices and files mapped
Shmem: 1084 kB:
Slab: 59840 kB: the size of the kernel data structure cache , can reduce the consumption caused by applying for and releasing memory
SReclaimable: 34196 kB: the size of the reclaimable Slab
SUnreclaim: 25644 kB: the size of the non-reclaimable Slab (SUnreclaim+SReclaimable=Slab)
KernelStack: 7504 kB: resident memory, each user thread will allocate a kernel stack (kernel stack)
PageTables: 15508 kB: index for managing memory paging pages Size of table
NFS_Unstable: 0 kB : Size of unstable page table
Bounce: 0 kB :
WritebackTmp: 0 kB :
CommitLimit: 1053080 kB : According to the overcommit ratio ('vm.overcommit_ratio'), this is currently allocated available on the system The total amount of memory, this limit is only enabled in mode 2 ('vm.overcommit_memory'). CommitLimit is calculated with the following formula: CommitLimit = ('vm.overcommit_ratio'*physical memory) + swap For example, on a system with 1G physical RAM and 7G swap, when `vm.overcommit_ratio` = 30 CommitLimit = 7.3G Committed_AS:
16368536 kB : The amount of memory currently allocated on the system. It is the sum of the memory requested by all processes, even if all the requested memory is not fully used, for example, a process applies for 1G memory and only uses 300M, but this 1G memory application has been "committed" to the VM virtual machine, the process Can be used at any time. If limited to mode 2('vm.
VmallocTotal: 245760 kB: the size of vmalloc virtual memory
VmallocUsed: 0 kB: the size of virtual memory used by vmalloc
VmallocChunk: 0 kB: the largest contiguous unused vmalloc area


1. Inactive(anon) and Inactive(file), which represent anonymous pages and mapped pages respectively.

The memory pages of the user process are divided into two types: the memory associated with the file (such as the memory page corresponding to the program file and the data file) and the memory not related to the file (such as the stack of the process, the memory requested by malloc), the former is called File pages or mapped pages, the latter is called anonymous pages; among them, LRU lists include the following types, and there are corresponding statistical values ​​in /proc/meminfo:

  LRU_INACTIVE_ANON – corresponds to Inactive(anon)
  LRU_ACTIVE_ANON – corresponds to Active(anon)
  LRU_INACTIVE_FILE – corresponds to Inactive(file)
  LRU_ACTIVE_FILE – corresponds to Active(file)
  LRU_UNEVICTABLE – corresponds to Unevictable

The Inactive list contains memory pages that have not been accessed for a long time, and the Active list contains memory pages that have been accessed recently. The LRU algorithm uses the Inactive list and Active list to determine which memory pages can be recycled first.

2、MemAvailable

The amount of memory available to the application. Although some memory in the system has been used, it can be recycled. For example, cache/buffer and slab can all be recycled, so MemFree cannot represent all available memory. This part of recyclable memory plus MemFree is the memory available to the system. That is: MemAvailable≈MemFree+Buffers+Cached, which is calculated by the kernel using a specific algorithm and is an estimated value.

3、VmallocUsed

The memory allocated by vmalloc is counted in the VmallocUsed value of /proc/meminfo, but it should be noted that this value not only includes the allocated physical memory, but also counts the values ​​of VM_IOREMAP, VM_MAP and other operations. For example, VM_IOREMAP maps IO addresses to the kernel space, does not consume physical memory, so we want to exclude them. From the perspective of physical memory allocation, we only care about the VM_ALLOC operation, which can be seen from the vmalloc record in /proc/vmallocinfo.

4、KernelStack:

Kernel stack (kernel stack) is a resident memory, neither included in the LRU lists, nor included in the RSS/PSS memory of the process, so we think it is the memory consumed by the kernel. The statistics are the KernelStack of /proc/meminfo. The task_struct size of the 64bit system is 16KB, and the task_struct size of the 32bit system is 8KB. Each user thread will allocate a kernel stack (kernel stack). Although the kernel stack belongs to the thread, the code in the user mode cannot be accessed. Only through the system call (syscall ), self-trap (trap) or exception (exception) will be used when entering the kernel mode, that is to say, the kernel stack is used for the kernel code.
 

Memory black hole:

By adding up the memory size in memoryinfo, the process finds that it is always smaller than the real memory. That is because of the existence of memory black holes. We know that Kernel's dynamic memory allocation is through the following interfaces:

alloc_pages/__get_free_page: allocate in units of pages

vmalloc: Allocate contiguous memory blocks with virtual addresses in bytes

slab allocator

The memory allocated by vmalloc and slab will be recorded in meminfo, but the memory allocated by alloc_pages/__get_free_page is not counted in /proc/meminfo. I don’t know how many there are, just like a black hole.

Refer to the blog "android cat /proc/meminfo field analysis"

Guess you like

Origin blog.csdn.net/a1809032425/article/details/128555991