Optional Parameters for the free command
- -b,-k,-m,-g show output in bytes, KB, MB, or GB
- -H human readable output (automatic unit scaling)
- -L Show detailed low and high memory statistics
- -O use old format (no-/+buffers/cache line)
- -t display total for RAM + swap
- -s update every [delay] seconds
- -c update [count] Times
- -A show available memory if exported by kernel (>80 characters per line)
- -V Display version information and exit
Common Parameters Demo
[Email protected] ~]# Free-b #以Byte为单位显示
Total used free shared buffers Cached
mem:1044611072 552603648 492007424 57344 39006208 124108800
-/+ buffers/cache:389488640 655122432
swap:1572855808 245936128 1326919680
[Email protected] ~]# free-k#以KB为单位显示
Total used free shared buffers Cached
mem:1020128 536520 483608 56 38108 121200
-/+ buffers/cache:377212 642916
swap:1535992 240172 1295820
[Email protected] ~]# free-m#以MB为单位显示
Total used free shared buffers Cached
mem:996 523 472 0 37 118
-/+ buffers/cache:368 627
swap:1499 234 1265
[Email protected] ~]# free-h #人性化输出显示
Total used free shared buffers Cached
mem:996m 521M 474M 56K 35M 118M
-/+ buffers/cache:368m 628M
swap:1.5g 234M 1.2G
[Email protected] ~]# free-o #不显示-/+buffers/cache line, not recommended
Total used free shared buffers Cached
mem:1020128 536892 483236 56 38468 121284
swap:1535992 240172 1295820
[Email protected] ~]# free-th #算上swap
Total used free shared buffers Cached
mem:996m 524M 471M 56K 37M 118M
-/+ buffers/cache:368m 627M
swap:1.5g 234M 1.2G
TOTAL:2.4G 758M 1.7G
[[Email protected] ~]# time free-s 1-c 3 #表示持续每隔1s更新更新一次mem信息, updated 3 times
Total used free shared buffers Cached
mem:1020128 537512 482616 56 38868 121328
-/+ buffers/cache:377316 642812
swap:1535992 240172 1295820
Total used free shared buffers Cached
mem:1020128 537512 482616 56 38868 121328
-/+ buffers/cache:377316 642812
swap:1535992 240172 1295820
Total used free shared buffers Cached
mem:1020128 537512 482616 56 38868 121328
-/+ buffers/cache:377316 642812
swap:1535992 240172 1295820
Real 0m2.002s
User 0m0.000s
SYS 0m0.001s
[Email protected] ~]#
Free
Command output result information description
Total used free shared buffers Cached
mem:996m 525M 470M 56K 38M 118M
-/+ buffers/cache:368m 627M
swap:1.5g 234M 1.2G
First line
- Total: Memory Totals
- Used: Amount of memory already in use
- Free: Fully idle memory
- Shared: Memory for multiple processes
- Buffers: for block device data buffering, recording file system metadata (directories, permissions, attributes, etc.)
- Cached: Buffering for file content
first column
- Mem: Physical Memory
- -/+ Buffers/cache: Based on the application perspective (calculate the memory used when the memory is subtracted from the Buffers/cache, calculate the memory can be used in addition to Buffers/cache), but also can be understood as true memory usage.
- Swap: Swap partition
when we get the system memory usage, we should use the "-/+ buffers/cached" line of used and free as reference. Because the first row of buffers and cached is cached by the system ( This includes buffering the metadata data and the previously opened content to speed up our system processing, which can be released at any time (or manually) based on our application memory usage.
Here's what my system available memory is actually: Available 627M, 368M is used instead of 525M and 470M.
Buffers/cahed Manual Release Test
Before release
[[email protected] ~]# free-h Total used free shared buffers cachedmem: 996M 531M 465M 56K 42M 119M-/+ buffers/cache: 369M 626MSwap: 1. 5G 234M 1
Manually release using commands
3 >/proc/sys/vm/drop_caches~]# free-h total used free shared Buffers cachedmem: 996M 391M 604M 56K 420K 26M -/+ buffers/cache: 364M 631MSwap: 1. 5G 234M 1 ~
After manual release we saw that the first line of Mem used and free had a big boost, and our view was verified
Use the Find command to increase buffers
[Email protected] backup]# free-h;find. >/dev/NULL; free-h total used free shared buffers cachedmem:996m 397M 598M 56K2.6M32M-/+ buffers/cache:362m 633MSwap:1.5G 234M1.2G
Total used free shared buffers cachedmem:996m 415M 581M 56K
17m 32M
-/+ buffers/cache:364m 631MSwap:1.5G 234M1. 2g[[email protected] backup]#
Use the cat command to increase cached
[Email protected] python]# free-h;find/mydata/backup/python/-type F|xargs cat>/dev/NULL 2>&1; free-h total used free shared buffers cachedmem:996m 434M 561M 56K 18M 50M -/+ buffers/cache:365m 630MSwap:1.5G 234M1. 2GTotal used free shared buffers cachedmem:996m 767M 228M 56K 20M 367M -/+ buffers/cache:379m 617MSwap:1.5G 234M1.2G
Done!!!
Use the free command to view the memory usage of Linux servers (-/+ buffers/cache detailed)