How do you calculate memory usage in Linux?
The memory usage of Linux can be obtained by calculating the ratio of available memory to total memory.
Firstly, you can check the system’s memory information using the following command:
free -m
This command will display information such as total system memory, used memory, and available memory.
In the output results, available memory can be obtained using either “MemAvailable” or “free + buffers/cache”.
The formula for calculating memory usage rate is:
内存占用率 = (总内存 - 可用内存) / 总内存 * 100%
By using the formula above, the memory utilization rate of the system can be calculated.