Linuxでユーザー空間プログラムに割り当てられたメモリの合計量を測定する方法は?これは、物理メモリ内のユーザー空間プログラムが所有するすべてのメモリページのサイズです。
/proc/meminfo
この情報は提供されていないようです。
rss
現在、すべてのプロセスのフィールドを追加していますが、/proc/$pid/stat
共有メモリページは考慮しません。
修正する:「ユーザースペース」とは、ルート(カーネルスペースではない)を含むすべてのユーザーが実行するプロセスを意味します。
ベストアンサー1
使用smem
交換せずに共有メモリを2回計算せずに、すべてのユーザーメモリの合計を表示します。
sudo smem -c pss -t | tail -1
私のシステムの出力:
4119846
拡大する:
-c pss
この場合は列を選択してください。PSS。からman smem
:smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been swapped out to disk.
-t
示すみんなまたは、最後に使用されたすべてのPSSの合計を取得し、tail -1
古いデータを削除します。
合計のみ表示共有されていませんユーザーメモリは-c pss
次のように置き換えられます-c uss
。
sudo smem -c uss -t | tail -1
出力:
3874356
上記のPSSの合計は、次に示す数字とほぼ同じです。行5、列2ここで:
smem -w
出力:
Area Used Cache Noncache
firmware/hardware 0 0 0
kernel image 0 0 0
kernel dynamic memory 1367712 1115708 252004
userspace memory 4112112 419884 3692228
free memory 570060 570060 0