Skip to main content

unittest PyPI - latest PyPI - Python

osmem

Shows memory usage information for process trees

Install

pip install osmem

Usage

Find out the top-n types of processes consuming most memory.

> osmem top -n 3

  PID  Aggregate  Process
-----  ---------  --------------------
 1516   12582 MB  firefox.exe
 3408    9048 MB  Code.exe
 4432    3627 MB  cmdagent.exe

Aggregates all processes with the same name, which makes it a whole lot easier to understand just how much memory all those tabs one forgets to close in firefox/chrome actually consume.

Get a break-down of all the processes on the system, how much memory each process consumes, and how the memory usage aggregates up through the process hierarchy.

> osmem tree

  PID  Aggregate   Memory  Process
-----  ---------  -------  --------------------
    0      12 MB     0 MB  System Idle Process
    4      12 MB     0 MB    System
  800                1 MB      smss.exe
 3216               10 MB      MemCompression
  168                0 MB
  276              119 MB  Registry
  688      11 MB     4 MB  cmd.exe
 1500                6 MB    conhost.exe
  920    5496 MB     1 MB  wininit.exe
 1088    5482 MB     7 MB    services.exe
    8                5 MB      svchost.exe
 1144                5 MB      svchost.exe
...

Since some processes are spawned several times with the same name, it may be beneficial to see the actual command line arguments for each process. For instance, "svchost" on windows or "sshd" / "bash" / "docker-proxy" on linux say very little about the specific nature of such a process.

> osmem tree -c

  PID  Aggregate   Memory  Process              Command
-----  ---------  -------  -------------------  --------------------
    0      12 MB     0 MB  System Idle Process
    4      12 MB     0 MB    System
  800                1 MB      smss.exe         \SystemRoot\System32\smss.exe
 3216               10 MB      MemCompression
  168                0 MB
  276              119 MB  Registry
  688      11 MB     4 MB  cmd.exe              C:\Windows\System32\cmd.exe
 1500                6 MB    conhost.exe        \??\C:\Windows\system32\conhost.exe 0x4
  920    5498 MB     1 MB  wininit.exe          wininit.exe
 1088    5484 MB     8 MB    services.exe       C:\Windows\system32\services.exe
    8                5 MB      svchost.exe      C:\Windows\system32\svchost.exe -k LocalSystemNetworkRestricted -p
 1144                4 MB      svchost.exe      C:\Windows\system32\svchost.exe -k LocalService -p -s nsi
...
$ osmem tree -c

  PID  Aggregate  Memory  Process              Command
-----  ---------  ------  -------------------  --------------------
    1     941 MB   11 MB  systemd  /sbin/init
  369              46 MB    systemd-journald   /lib/systemd/systemd-journald
  408               7 MB    systemd-udevd      /lib/systemd/systemd-udevd
  501               4 MB    rpcbind            /sbin/rpcbind -f -w
...

For *nix users, this is somewhat similar to ps -wwef but gets you the memory usage as well, and the memory aggregation.

Development

To execute the main function of the programs, either of the following options are viable

  • osmem as a CLI
  • python -m osmem as a python package

To simplify development, common actions are provided via Makefile targets:

  • test - default targets, runs pytest on the project
  • lint - performs flake8 and mypy linting
  • build - create a wheel package distribution, ready to be shared with someone else.
  • clean - removes temporary files generated as part of the package creation.

Metadata

Release files for osmem 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for osmem 0.3.2
File Interpreter ABI Platform
osmem-0.3.2-py3-none-any.whl Python 3 none any Details

Release files / osmem-0.3.2-py3-none-any.whl

Download URL osmem-0.3.2-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05a73c6a3584dc0974ca7ab77ef8e0b5d5c50e6e1e522f3c29ddedf65b44ba99
BLAKE2b-256 checksum
How to use checksums
584837d28a06c358a8af10f1259d57d40575aa23d85c8e036845fab4ec4a7003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.9.24 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

0.3.2 This release

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page