https://blog.csdn.net/xiangliangyu/article/details/8213127
$ sudo pacman -S iotoplinux
https://blog.longwin.com.tw/2017/02/linux-find-use-swap-process-2017/
單純使用到 swap 的 PID 列表可查 /proc/*/status 的 VmSwap 值
$ grep VmSwap /proc/*/status 正則表達式
查看那些進程使用了swap:
$ for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less app
https://stackoverflow.com/questions/30481314/how-can-i-know-which-process-is-using-swap
https://stackoverflow.com/questions/479953/how-to-find-out-which-processes-are-using-swap-space-in-linux
查看那些進程使用了swap:(改進版)
$ (echo "COMM PID SWAP"; for file in /proc/*/status ; do awk '/^Pid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | grep -wv "0 kB" | sort -k 3 -n -r) | column -t less
https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/
$ sudo pacman -S smem
$ smem
要查看面向庫的視圖,請輸入:
# smem -mthis
要查看面向用戶的視圖,請輸入:
$ sudo smem -u
[sudo] password for toma:
User Count Swap USS PSS RSS
rtkit 1 236 68 85 1356
dbus 1 296 804 878 2388
polkitd 1 4860 1956 1995 4400
root 14 26064 106560 127519 173776
toma 89 87412 3092876 3294633 7503088
$ spa
要查看系統範圍的內存使用狀況摘要,請傳遞-w選項:
$ sudo smem -w
Area Used Cache Noncache
firmware/hardware 0 0 0
kernel image 0 0 0
kernel dynamic memory 4509624 4305388 204236
userspace memory 3424012 422456 3001556
free memory 225776 225776 0
$ .net
查看系統視圖
$ sudo smem -R 8G -K /path/to/vmlinux/on/disk -w
size: '/path/to/vmlinux/on/disk': No such file
Parameter '/path/to/vmlinux/on/disk' should be an original uncompressed compiled kernel file.blog
Area Used Cache Noncache
firmware/hardware 229196.0 0 229196.0
kernel image 0 0 0
kernel dynamic memory 4521572 4314964 206608
userspace memory 3448996 422668 3026328
free memory 188844 188844 0
$ 排序
要查看總計和百分比,請輸入:
$ sudo smem -t -p
PID User Command Swap USS PSS RSS
518 toma /bin/sh /etc/xdg/xfce4/xini 0.01% 0.00% 0.00% 0.01%
753 toma /usr/lib/ibus/ibus-engine-s 0.01% 0.00% 0.00% 0.02%
......
106 5 1.42% 39.57% 42.28% 94.51% 進程
# smem --help -h, --help show this help message and exit -H, --no-header disable header line 禁用標題行 -c COLUMNS, --columns=COLUMNS columns to show 要顯示的列 -t, --totals show totals 顯示總數 -a, --autosize size columns to fit terminal size -R REALMEM, --realmem=REALMEM amount of physical RAM 物理RAM的數量 -K KERNEL, --kernel=KERNEL path to kernel image 內核映像的路徑 -m, --mappings show mappings 顯示映射 -u, --users show users 顯示用戶 -w, --system show whole system 顯示整個系統 -P PROCESSFILTER, --processfilter=PROCESSFILTER process filter regex 進程過濾器正則表達式 -M MAPFILTER, --mapfilter=MAPFILTER map filter regex 地圖過濾器正則表達式 -U USERFILTER, --userfilter=USERFILTER user filter regex 用戶過濾器正則表達式 -n, --numeric numeric output 數字輸出 -s SORT, --sort=SORT field to sort on 要排序的SORT字段 -r, --reverse reverse sort 反向排序 -p, --percent show percentage 顯示百分比 -k, --abbreviate show unit suffixes 顯示單位後綴k --pie=PIE show pie graph 顯示餅圖 --bar=BAR show bar graph 顯示條形圖 -S SOURCE, --source=SOURCE /proc data source /proc數據源