procps工具集 ----Linux中的可用內存指的是什么?【轉】


轉自:https://www.cnblogs.com/zengkefu/p/5654346.html

https://gitlab.com/procps-ng/procps

 

復制代碼
free - Report the amount of free and used memory in the system
kill - Send a signal to a process based on PID
pgrep - List processes based on name or other attributes
pkill - Send a signal to a process based on name or other attributes
pmap - Report memory map of a process
ps - Report information of processes
pwdx - Report current directory of a process
skill - Obsolete version of pgrep/pkill
slabtop - Display kernel slab cache information in real time
snice - Renice a process
sysctl - Read or Write kernel parameters at run-time
tload - Graphical representation of system load average
top - Dynamic real-time view of running processes
uptime - Display how long the system has been running
vmstat - Report virtual memory statistics
w - Report logged in users and what they are doing
watch - Execute a program periodically, showing output fullscreen
復制代碼

 

1、從meminfo文件中查看可用內存:

從Linux kernel-3.14和2.6.27+ 開始,在/proc/meminfo中提供了可用內存MemAvailable值。

 

kernel 中的available 介紹:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773

 

檢查/proc/meminfo文件,通過將“MemFree + Buffers+ Cached”相加,預估有多少可用內存,這在十年前是可以,但是在今天肯定是不對的。

 

因為緩存包含存不能釋放的page cache,例如shared memory segments、tmpfs、ramfs,它不包括可收回的slab內存,比如在大多數空閑的系統中,存在很多文件時,它會占用大量的系統內存。

 

在系統沒有發生交換時,預估需要多少available內存才可以啟動新的應用程序。這個available字段不同於cache或free字段所提供的數據,它除了要考慮到page cache,還要考慮到當項目在使用時,並不是所有的slabs都能被回收這一情況。

 

從proc/meminfo文件中查看可用內存:

 

[root@server-mysql]# /usr/local/bin/free
              total        used        free      shared  buff/cache   available
Mem:        1364828      175720      956704        1168      232404     1064754
Swap:       3071992           0     3071992
[root@server-mysql procps-master]# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.3G        171M        934M        1.1M        227M        1.0G
Swap:          2.9G          0B        2.9G

 

 

2、使用free命令查看可用內存:

我們一般都使用“free”命令來獲得系統的內存使用情況,但是一些老版本的的“procps”包沒有包含查看“Available”的參數,可以通過升級“procps”程序來查看“Available”內存值。

 

procps升級方式(需要大於等於autoconf-2.69支持)

# git clone https://gitlab.com/procps-ng/procps.git

# cd procps

# ./autogen.sh

# ./configure && make&& make install

 

查看不同free版本顯示可用內存的區別:

 

/usr/bin/free是系統自帶的命令。

 

 

/usr/local/bin/free是下載最新的procps包編譯安裝的命令。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM