ps_mem shows the memory usage of each program on Linux

ps_mem Is a tool for checking the core memory usage of each program on Linux. It works with Python 2 and 3 and has no dependencies other than Python. ps_mem reports the RAM usage of a program, unlike many other tools that report the memory usage of each process. For example, it shows how much RAM is used by all Chromium processes in total. Program developers notice that the ps_mem name is used for backward compatibility, but the more accurate name is coremem.
The RAM shown is obtained by adding the sum of the dedicated RAM to the sum of the shared RAM processed by the program.

Running ps_mem without any parameters will display the listing program and its RAM usage in ascending order (from the lowest RAM usage to the highest RAM). For each program, it shows how much RAM is dedicated, shared, and total used, as well as the number of processes. By using the -S option, the exchange information of each program can also be displayed (sudo ps_mem -S).
This is the output of ps_mem (trimmed because it is long):

[email protected]:~$ sudo ps_mem
 Private  +   Shared  =  RAM used Program

192.0 KiB +   6.5 KiB = 198.5 KiB nvidia-persistenced
220.0 KiB +   9.5 KiB = 229.5 KiB vnstatd
232.0 KiB +   7.5 KiB = 239.5 KiB acpid
232.0 KiB +  18.5 KiB = 250.5 KiB atd
236.0 KiB +  41.5 KiB = 277.5 KiB blkmapd
..........................................................
 35.3 MiB +   4.3 MiB =  39.6 MiB goa-daemon
 52.3 MiB +  24.0 MiB =  76.3 MiB Xorg (2)
 81.4 MiB +  13.7 MiB =  95.0 MiB systemd-journald
364.8 MiB +  26.0 MiB = 390.8 MiB gnome-shell (2)
  1.2 GiB + 121.0 MiB =   1.3 GiB firefox-trunk (11)
---------------------------------
                          7.6 GiB
=================================

ps_mem can also display the memory usage of each process instead of displaying it programmatically by using it with the -d option (sudo ps_mem -d).
The tool allows filtering results by PID. An example of a useful use case is shown in the ps_mem readme-limiting ps_mem output to the current user:

sudo ps_mem -p $(pgrep -d, -u $USER)

These are the options supported by ps_mem:

$ ps_mem --help
Usage: ps_mem [OPTION]...
Show program core memory usage

  -h, -help                   Show this help
  -p [,pid2,...pidN]     Only show memory usage PIDs in the specified list
  -s, --split-args            Show and separate by, all command line arguments
  -t, --total                 Show only the total value
  -d, --discriminate-by-pid   Show by process rather than by program
  -S, --swap                  Show swap information
  -w                       Measure and show process memory every N seconds

Install ps_mem

ps_mem is available in repositories for Fedora, RHEL, CentOS, and Arch Linux. You can install it using the following methods.
Fedora:

sudo dnf install ps_mem

CentOS / RHEL:

sudo yum install ps_mem

Arch Linux:

sudo pacman -S ps_mem

In other Linux distributions (such as Debian, Ubuntu, etc.) they do not have ps_mem in their repositories, you can download the Python script and install it to /usr/local/bin use:

wget https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py
sudo install ps_mem.py /usr/local/bin/ps_mem
rm ps_mem.py

You can also install ps_mem using PIP (pip install ps_mem). Use it by running sudo ps_memOr ps_mem --help See available options.
Pass @m_wimpress


Source

Sidebar