System Administration

Essential System Tools: ps_mem – accurately report memory usage of programs

Last Updated on May 28, 2022

This is the first in a series of articles highlighting essential system tools. These are small utilities, useful for system administrators as well as regular users of Linux based systems. The series will examine both graphical and text based open source utilities. For details of all tools in this series, please check the table in the summary section.

The first tool under the spotlight is ps_mem, a small utility that reliably reports how much memory is consumed by an application.

Linux has many utilities that report memory usage such as free, top, and ps. What makes ps_mem different? Read on.

Installation

Many distributions provide a convenient package for ps_mem. For example, the software is included in the community repository in Manjaro. And you can install the script using pip.

There’s also a Python script that’s available from the project’s GitHub code repository that doesn’t require any installation.

In operation

Here’s a sample of the output from the utility.  The first memory column shows the amount of private RAM being used by the program, with the second column shows the shared RAM. The third column shows the total RAM used by the program. As you can see, Thunderbird and Firefox are consuming significant dollops of RAM.

ps_mem

One of the uses of ps_mem is to compare the memory usage of a specific type of software. For example, the screenshot below captures the memory usage of five web browsers: Firefox, Chromium, Opera, Midori, and w3m, all viewing a single identical web page. Unsurprisingly w3m consumes the least amount of RAM; it’s a text-based web browser.

ps_mem

There’s still some interpretation required to make valid comparisons. For example, ps_mem reports Firefox memory in 2 lines. If you have extensions running, they’ll be a third line.

143.3 MiB + 40.2 MiB = 183.6 MiB Web Content (2)
194.4 MiB + 34.0 MiB = 228.4 MiB firefox

Midori’s memory usage is reported in 3 lines:

16.8 MiB + 5.2 MiB = 21.9 MiB WebKitNetworkProcess
26.9 MiB + 10.9 MiB = 37.7 MiB midori
201.6 MiB + 12.8 MiB = 214.4 MiB WebKitWebProcess

This reporting issue applies to version 3.12. But if you use the latest Python code from the GitHub code repository, memory reported is now grouped for Firefox, although not for Midori.

Other Options

The software can show memory usage by specific PIDs, show only the total amount of memory used (which is intended for automated tools), as well as showing memory usage by processes rather than by programs.

There’s also the option to show swap information, filter the results, as well as measuring and showing process memory every N seconds.

Summary

ps_mem is a very handy utility. It interrogates the kernel to obtain the memory information, outputting the information in a clean and uncluttered way. It’s awesome software.

Website: github.com/pixelb/ps_mem
Support:
Developer: Pádraig Brady, Andres Riancho, Facundo Victor, and other contributors
License: GNU Lesser General Public License v2.1

ps_mem is written in Python. Learn Python with our recommended free books and free tutorials.


All the essential tools in this series:

Essential System Tools
AlacrittyInnovative, hardware-accelerated terminal emulator
BleachBitSystem cleaning software. Quick and easy way to service your computer
bottomGraphical process/system monitor for the terminal
btop++Monitor usage and stats for CPU, memory, disks, network and processes
catfishVersatile file searching software
ClonezillaPartition and disk cloning software
CPU-XSystem profiler with both a GUI and text-based
CzkawkaFind duplicate files, big files, empty files, similar images, and much more
ddrescueData recovery tool, retrieving data from failing drives as safely as possible
dustMore intuitive version of du written in Rust
f3Detect and fix counterfeit flash storage
Fail2banBan hosts that cause multiple authentication errors
fdupesFind or delete duplicate files
FirejailRestrict the running environment of untrusted applications
GlancesCross-platform system monitoring tool written in Python
GPartedResize, copy, and move partitions without data
GreenWithEnvyNVIDIA graphics card utility
gtopSystem monitoring dashboard
gWakeOnLANTurn machines on through Wake On LAN
hyperfineCommand-line benchmarking tool
HyFetchSystem information tool written in Python
inxiCommand-line system information tool that's a time-saver for everyone
journalctlQuery and display messages from the journal
kmonManage Linux kernel modules with this text-based tool
KrusaderAdvanced, twin-panel (commander-style) file manager
NmapNetwork security tool that builds a "map" of the network
nmonSystems administrator, tuner, and benchmark tool
nnnPortable terminal file manager that's amazingly frugal
petSimple command-line snippet manager
PingnooGraphical representation for traceroute and ping output
ps_memAccurate reporting of software's memory consumption
SMCMulti-featured system monitor written in Python
TimeshiftReliable system restore tool
QDirStatQt-based directory statistics
QJournalctlGraphical User Interface for systemd’s journalctl
TLPMust-have tool for anyone running Linux on a notebook
UnisonConsole and graphical file synchronization software
VeraCryptStrong disk encryption software
VentoyCreate bootable USB drive for ISO, WIM, IMG, VHD(x), EFI files
WTFPersonal information dashboard for your terminal
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Please read our FAQ before making a comment.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments