Linux free command usage and Analysis
1. Command Format
Free [parameter]
2. command functions
The free command displays system usage and idle memory, including physical memory, interactive zone memory (swap), and kernel buffer memory. The shared memory is ignored.
3. Command Parameters
-B displays memory usage in bytes. -K displays memory usage in KB. -MB: memory usage is displayed in MB. -G displays memory usage in GB. -H automatic conversion unit (most commonly used)-o does not display the buffer adjustment column. -S <interval seconds> continuous observation of memory usage. -T: displays the total memory column. -V displays the version information.
4. Output Parsing
[zhangchengfei@Master:~]$free total used free shared buffers cachedMem: 16079364 14901460 1177904 5278136 65408 5921568-/+ buffers/cache: 8914484 7164880Swap: 12223484 1388724 10834760
free
All output values of the command are from/proc/meminfo
. Herefree
There are four rows of output, which are explained in sequence below:
4.1
Mem
Line Parsing
This line of output is from the operating system (OS), that is, from the OS perspective, there are a total of computers:
16079364KB
(Default unit: KB) physical memory.14901460KB
Used; also used1177904
KB is available;
Here is an equation:
Mem.total = Mem.used + Mem.free
shared
Memory shared by several processes, usedIPC
, Now deprecated, but it is displayed on my machine, mainly depends onfree
How is the command implemented.
buffer
Memory of the System buffer, used to store data to be output to disk (Block device.
cached
Memory cached by the system, used to store data read from disk.
The original English version is explained below, both of which are intended to improve IO performance.
A buffer is something that has yet to be “written” to disk.
A cache is something that has been “read” from the disk and stored for later use.
Release Data occupied by system cache;
echo 3>/proc/sys/vm/drop_caches
4.2
-/+ buffers/cache
Line Parsing
This row is used to view the system memory usage from the application perspective.
used
Indicates how much memory the application considers the system to have used;
free
Indicates how much memory the application considers the system to have;
Because the systemcache
Andbuffer
The occupied memory can be quickly recycled.free
.
There are two equations:
(-/+buffer/cache).used = Mem.used - Mem.buffers - Mem.cached(-/+buffer/cache).free = Mem.free + Mem.buffers + Mem.cached
4.3
Swap
Line Parsing
This behavior exchanges partition information, namely, the total amount of swap, the amount of used, and the number of idle swap areas ).
[End]
This article permanently updates the link address: