Home  >  Article  >  Operation and Maintenance  >  What is the command to check the memory size in Linux?

What is the command to check the memory size in Linux?

藏色散人
藏色散人Original
2023-01-05 14:06:137756browse

The command to check the memory size in Linux is the "What is the command to check the memory size in Linux?" command; you can check the system's memory usage through the "What is the command to check the memory size in Linux?" command, and the memory size unit is KB; you can check the system's memory usage through the "What is the command to check the memory size in Linux? -m" command , the memory size unit is MB; use the "What is the command to check the memory size in Linux? -g" command to check the system's memory usage, the memory size unit is GB.

What is the command to check the memory size in Linux?

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

What is the command to check the memory size in Linux?

Check the actual available memory size of the Linux system through the What is the command to check the memory size in Linux? command

##1. Free command

Use the

What is the command to check the memory size in Linux? command to check the memory usage of the system. The memory size unit is KB. The execution result is as shown in the figure below:
What is the command to check the memory size in Linux? Use the
What is the command to check the memory size in Linux? -m command to check the memory usage of the system. The memory size unit is MB. The execution result is as shown below:
What is the command to check the memory size in Linux? -m Through
The What is the command to check the memory size in Linux? -g command checks the memory usage of the system. The unit of memory size is GB. The execution result is as shown in the figure below:
What is the command to check the memory size in Linux?

2. Actual available memory size Calculate

From the picture above, after the

What is the command to check the memory size in Linux? command is executed, two lines of data Mem and Swap will be displayed, where Mem represents the usage of physical memory, Swap represents the usage of Swap partition.

What is Swap partition?

The Swap partition is a space opened by the operating system on the hard disk. When the physical memory block is exhausted, the system will transfer the memory of some processes that have not been used for a long time to the Swap partition; when the physical memory is released, the Swap The data in the area will gradually be returned to the physical memory as the process uses it.

1. Mem attribute description is shown in the following table:

AttributeAttribute valueDescriptiontotal8192MBTotal physical memory sizeused601MBPhysical memory size usedWhat is the command to check the memory size in Linux?3998MBNot allocated Physical memory sizeshared0MBShared physical memory sizebuff/cache3591MBIn order to improve the read and write speed of the system (including disk read and write, file inode read and write, etc.), the operating system uses part of the memory as a cache. This value is occupied by the cache. Physical memory sizeavailable3998MBAvailable physical memory size

2. See the table below for Swap attribute description:

AttributeAttribute valueDescriptiontotal0MBThe total size of the Swap partitionused0MBUsed Swap partition sizeWhat is the command to check the memory size in Linux?0MBUnused Swap partition size

3. Not considering the Swap partition
According to the above table, without considering the Swap partition, the memory calculation is as follows:
Total memory size: Mem.total = Mem.used Mem .What is the command to check the memory size in Linux? Mem.shared Mem.buff/cache
Theoretically the actual available memory size: Mem.actual = Mem.total - Mem.used - Mem.shared = Mem.What is the command to check the memory size in Linux? Mem.buff/cache

4. Consider Swap partition
According to the above table, when considering Swap partition, the memory calculation is as follows:
Total memory size: Mem.total = Mem.used Mem.What is the command to check the memory size in Linux? Mem.shared Mem.buff/cache
Theoretically the actual available memory size: Mem.actual = Mem.total - Mem.used - Mem.shared Swap.What is the command to check the memory size in Linux? = Mem.What is the command to check the memory size in Linux? Mem.buff/cache Swap.What is the command to check the memory size in Linux?

5. Available size recommended by the system available
available Official definition:

MemAvailable: An estimate of how much memory is available for starting new applications, without swapping. Calculated from MemFree, SReclaimable, the size of the file LRU lists, and the low watermarks in each zone. The estimate takes into account that the system needs some page cache to function well, and that not all reclaimable slab will be reclaimable, due to items being in use. The impact of those factors will vary from system to system.

available Translation:

memavailable: It is an estimate and does not take into account Swap partitions In this case, estimate how much memory is available to start the new application. Calculations are based on the size of memWhat is the command to check the memory size in Linux?, recyclable page cache, slab cache, LRU queue, and the low water mark in each region. This estimate takes into account that the system requires some page cache to function properly, and that not all reclaimable slabs can be reclaimed due to use by some programs. The impact of these factors varies from system to system.

available calculation formula is shown in the figure below:
What is the command to check the memory size in Linux?

The formula is summarized as:
Mem.available = Mem.What is the command to check the memory size in Linux? PageCache.size SlabCache.size - WaterMark .low

# #PageCache.size0MBThe size of PageCache that can be recycled, the calculation formula is shown in the figure aboveSlabCache.size0MB The SlabCache size that can be recycled, the calculation formula is shown in the figure aboveWaterMark.low0MBThe minimum supported system usage Water level, the calculation formula is shown in the figure above
Attribute Attribute value Description
Therefore, without considering the Swap partition, it is recommended to determine the actual available content of the system through the available parameter. The content of the article only represents my personal views. If there is anything wrong, I welcome criticism and correction. Thank you all.

Recommended learning: "

Linux Video Tutorial"

The above is the detailed content of What is the command to check the memory size in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn