Skip to main content

Shows memory usage information for process trees

Project description

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.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osmem-0.3.2-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file osmem-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: osmem-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.24 Linux/6.11.0-1018-azure

File hashes

Hashes for osmem-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05a73c6a3584dc0974ca7ab77ef8e0b5d5c50e6e1e522f3c29ddedf65b44ba99
MD5 c86703b3728dbf4bf5b4ed91d61a9645
BLAKE2b-256 584837d28a06c358a8af10f1259d57d40575aa23d85c8e036845fab4ec4a7003

See more details on using hashes here.

Supported by

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