Skip to main content

Track the RAM usage (resident set size) of a process and its descendants in real time.

Project description

memsparkline

Track the RAM usage (resident set size) of a process, its children, its children's children, etc. in real time with a Unicode text sparkline. See the average and the maximum usage after the process exits, as well as the run time.

Examples

> memsparkline -- chromium-browser --incognito http://localhost:8081/
▁▁▁▁▄▇▇▇█ 789.5
 avg: 371.0
 max: 789.5
time: 0:00:12.0
> memsparkline -n -o log du /usr/ >/dev/null 2>&1 &
> tail -f log
█ 2.8
▆█ 3.3
▆▇█ 3.6
▆▇▇█ 3.9
▆▇▇█▆ 3.3
▆▇▇█▆▆ 3.3
▆▇▇█▆▆▆ 3.3
▆▇▇█▆▆▆▆ 3.3
▄▅▅▆▅▅▅▅█ 5.2
▄▅▅▆▅▅▅▅██ 5.2
 avg: 3.7
 max: 5.2
time: 0:00:10.1

Compatibility and limitations

memsparkline works on POSIX systems supported by psutil. It has been tested on Debian, Ubuntu, FreeBSD, NetBSD, and OpenBSD. It seems to work on Windows, but Windows support has received minimal testing. The sparkline displays incorrectly in the Command Prompt and ConEmu on Windows 7 with the stock console fonts but correctly on Windows 10 with the font NSimSun.

memsparkline measures run time less precisely than time(1). The granularity with which it measures run time depends on the --wait option.

Installation

memsparkline requires Python 3.7 or later.

Installing from PyPI

The recommended way to install memsparkline is from PyPI with pipx.

pipx install memsparkline

You can also use pip:

pip install --user memsparkline

Manual installation

  1. Install the dependencies from package repositories for your OS. You will find instructions for some operating systems below.
  2. Download src/memsparkline/main.py and copy it to a directory in PATH as memsparkline. For example,
git clone https://gitlab.com/dbohdan/memsparkline
cd memsparkline
sudo install src/memsparkline/main.py /usr/local/bin/memsparkline

Dependencies

Debian/Ubuntu
sudo apt install python3-psutil
DragonFly BSD 6.6, FreeBSD 13.1
sudo pkg install py39-psutil
NetBSD 9.3
sudo pkgin in py310-psutil
OpenBSD
doas pkg_add py3-psutil

Usage

usage: memsparkline [-h] [-v] [-d path] [-l n] [-m fmt] [-n] [-o path] [-q]
                    [-t fmt] [-w ms]
                    command ...

Track the RAM usage (resident set size) of a process and its descendants in
real time.

positional arguments:
  command               command to run
  arg                   arguments to command

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -d path, --dump path  file to which to write full memory usage history when
                        finished
  -l n, --length n      sparkline length (default: 20)
  -m fmt, --mem-format fmt
                        format string for memory amounts (default: "%0.1f")
  -n, --newlines        print new sparkline on new line instead of over
                        previous
  -o path, --output path
                        output file to append to ("-" for standard error)
  -q, --quiet           do not print sparklines, only final report
  -t fmt, --time-format fmt
                        format string for run time (default: "%d:%02d:%04.1f")
  -w ms, --wait ms      how long to wait between taking samples (default:
                        1000)

License

MIT.

See also

memusg and spark inspired this project.

Tracking memory usage

Sparklines

  • spark — a Bash script that generates a Unicode text sparkline from a list of numbers.
  • sparkline.tcl — a Tcl script by the developer of this project that does the same. Adds a --min and --max option for setting the scale.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memsparkline-0.5.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

memsparkline-0.5.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file memsparkline-0.5.1.tar.gz.

File metadata

  • Download URL: memsparkline-0.5.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/6.2.0-39-generic

File hashes

Hashes for memsparkline-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3460a0be1fcf9a6c2890c091be53d983df66a691a0e37f1454f5206792575033
MD5 48cf4d35eba2e0a34eeaec45b46160e0
BLAKE2b-256 8e5d89530f054e60bb5c9a18a1e24dcb12d304d1285438f2d94f33408c4d2082

See more details on using hashes here.

File details

Details for the file memsparkline-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: memsparkline-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/6.2.0-39-generic

File hashes

Hashes for memsparkline-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27001219d951848441f10babc4c78aa746ef0baaa24f3da0b36a7f4cc02ae280
MD5 dce5f742ad662d6b598a15a4b8c7937d
BLAKE2b-256 5cd2f1729c57af46950b8d9b277fe3815a2fce707416a82d6422f30cf3a905e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page