free命令查看內存信息
阿新 • • 發佈:2018-07-22
detail meminfo roo written standby tables rip inactive comm
free介紹
FREE(1) Linux User’s Manual FREE(1) NAME free - Display amount of free and used memory in the system SYNOPSIS free [-b | -k | -m] [-o] [-s delay ] [-t] [-l] [-V] DESCRIPTION free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The shared memory column should be ignored; it is obsolete. Options The -b switch displays the amount of memory in bytes; the -k switch (set by default) displays it in kilobytes; the -m switch displays it in megabytes. The -t switch displays a line containing the totals. The -o switch disables the display of a "buffer adjusted" line. If the -o option is not speci- fied, free subtracts buffer memory from the used memory and adds it to the free memory reported. The -s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times. The -l switch shows detailed low and high memory statistics. The -V switch displays version information. FILES /proc/meminfo-- memory information SEE ALSO ps(1), slabtop(1), vmstat(8), top(1) AUTHORS Written by Brian Edmonds. Send bug reports to <[email protected]> Cohesive Systems 20 Mar 1993 FREE(1)
free示例
root@71standby[12:20:25]$ free && echo ‘‘ && cat /proc/meminfo total used free shared buffers cached Mem: 32880252 7804824 25075428 2836 397504 5559752 -/+ buffers/cache: 1847568 31032684 Swap: 2064380 0 2064380 MemTotal: 32880252 kB MemFree: 25075428 kB Buffers: 397504 kB Cached: 5559752 kB SwapCached: 0 kB Active: 2778440 kB Inactive: 4535288 kB Active(anon): 1356660 kB Inactive(anon): 2640 kB Active(file): 1421780 kB Inactive(file): 4532648 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 2064380 kB SwapFree: 2064380 kB Dirty: 160 kB Writeback: 0 kB AnonPages: 1356472 kB Mapped: 32648 kB Shmem: 2836 kB Slab: 259528 kB SReclaimable: 221788 kB SUnreclaim: 37740 kB KernelStack: 5776 kB PageTables: 18332 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 18504504 kB Committed_AS: 3346884 kB VmallocTotal: 34359738367 kB VmallocUsed: 66544 kB VmallocChunk: 34359658428 kB HardwareCorrupted: 0 kB AnonHugePages: 806912 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 6012 kB DirectMap2M: 2091008 kB DirectMap1G: 31457280 kB root@71standby[12:20:30]$
字段解釋
>>> # free 默認單位是KB >>> >>> 32880252-7804824 # 總內存 - 已使用內存 == 剩余可用內存 25075428 >>> >>> 7804824-397504-5559752 # 已使用內存分為三部分:應用程序占用的內存 + buffers + cached 1847568 # 所以當前服務器上應用程序一共占用了 1847568KB內存 >>> >>> 25075428+397504+5559752 # 全部可用內存 = 剩余可用內存 + buffers + cached 31032684 # 所以當前服務器上可以實際使用的內存為 31032684KB >>>
buffers和cached是幹啥用的?
cached是cpu與內存間的,buffer是內存與磁盤間的,都是為了解決速度不對等的問題。
buffer是即將要被寫入磁盤的,而cache是被從磁盤中讀出來的。
- 緩存(cached)是把讀取過的數據保存起來,重新讀取時若命中(找到需要的數據)就不要去讀硬盤了,若沒有命中就讀硬盤。
其中的數據會根據讀取頻率進行組織,把最頻繁讀取的內容放在最容易找到的位置,把不再讀的內容不斷往後排,直至從中刪除。
- 緩沖(buffers)是根據磁盤的讀寫設計的,把分散的寫操作集中進行,減少磁盤碎片和硬盤的反復尋道,從而提高系統性能。
linux有一個守護進程定期 清空緩沖內容(即寫入磁盤),也可以通過sync命令手動清空緩沖。
舉個例子吧:我這裏有一個ext2的U盤,我往裏面cp一個3M的MP3,但U盤的燈 沒有跳動,過了一會兒(或者手動輸入sync)U盤的燈就跳動起來了。
卸載設備時會清空緩沖,所以有些時候卸載一個設備時要等上幾秒鐘
- swappiness 修改/etc/sysctl.conf中的vm.swappiness右邊的數字可以在下次開機時調節swap使用策略。
該數字範圍是0~100,數字越大越傾向於使用swap。默認為60,可以改一下試試。–兩者都是RAM中的數據。
轉自:https://www.cnblogs.com/chenpingzhao/p/5161844.html
free命令查看內存信息