To view the memory in Linux, we generally use the free command:
[Root @ scs-2 TMP] # Free
Total used free shared buffers cached
Mem: 3266180 3250004 16176 0 110652 2668236
-/+ Buffers/cache: 471116 2795064
Swap: 2048276 80160 1968116
The following is an explanation of these values:
Total: total physical memory size.
Used: used.
Free: available.
Shared: The total memory shared by multiple processes.
Buffers/cached: disk cache size.
(-/+ Buffers/cached ):
(-Buffers/cache) used memory size: 286 MB (refers to used-Buffers-cached in the first part of the mem row)
(+ Buffers/cache) free memory: 715 MB (refers to the first part of the mem row free + buffers + cached)
The third line indicates that, from the application perspective, for applications, buffers/cached is equivalent to available, because buffer/cached is designed to improve file read performance, when the application needs to use the memory, buffer/cached will be quickly recycled. From the application perspective, the available memory = system free memory + buffers + cached.
For example:
2795064 = 16176 + 110652 + 2668236
It can be seen that-Buffers/cache reflects the memory actually eaten by the program, while + buffers/cache reflects the total number of memories that can be used.
[Root @ scs-2 TMP] # Free-m
Total used free shared buffers cached
Mem: 3189 3173 16 0 107 2605
-/+ Buffers/cache: 460 2729
Swap: 2000 78 1921
After the-M parameter is added, the unit is MB.
When we run the free command to view the idle memory of the machine, we will find that the free value is very small. This is mainly because there is such an idea in Linux, the memory does not need to be white, so it tries its best to cache and buffer some data for the next use. But in fact, these memories can also be used immediately.
So free memory = free + buffers + cached = total-used
[Root @ scs-2 TMP] # Cat/proc/meminfo
Memtotal: 3266180 KB
Memfree: 17456 KB
Buffers': 111328 KB
Cached: 2664024 KB
Swapcached: 0 KB
Active: 467236 KB
Inactive: 2644928 KB
Hightotal: 0 KB
Highfree: 0 KB
Lowtotal: 3266180 KB
Lowfree: 17456 KB
Swaptotal: 2048276 KB
Swapfree: 1968116 KB
Dirty: 8 KB
Writeback: 0 KB
Mapped: 345360 KB
Slab: 112344 KB
Committed_as: 535292 KB
Pagetables: 2340 KB
Vmalloctotal: 536870911 KB
Vmallocused: 272696 KB
Vmallocchunk: 536598175 KB
Hugepages_total: 0
Hugepages_free: 0
Hugepagesize: 2048 KB
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 memory size used by high-speed buffer memory (cache memory) (equal to diskcache minus swapcache ).
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 and highfree: this region is not directly mapped to the kernel space. The kernel must use the memory in different ways.
Lowtotal and lowfree: low levels can achieve the same effect as high memory, and it can also be used by the kernel to record some of its own data structures.
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.
Vmalloctotal: vmalloc virtual memory size
Vmallocused: the virtual memory size used.
:
[Root @ localhost ~] # Free Total used free shared buffers cached Mem: 1939980 768720 1171260 0 40852 483720 -/+ Buffers/cache: 244148 1695832 Swap: 2096472 0 2096472 [Root @ localhost ~] # Vmstat Procs ----------- memory ---------- --- swap -- ----- Io ---- System -- ----- CPU ------ R B SWPD free buff cache Si so Bi Bo in CS us Sy ID wa st 0 0 0 1171260 40852 483720 0 33 11 91 186 1 2 96 1 0 |