ps-mem is a Python utility designed to accurately report the core memory usage per program on Linux, distinguishing itself from tools that report per-process. It calculates RAM usage by summing both private and shared memory across all processes belonging to a given program. The current stable version is 3.14, released in May 2022, and it operates as a command-line tool, primarily written in Python 3, though it also supported Python 2.
pip install ps-memVerified import paths — ran on the pinned version, not inferred.
The primary way to use ps-mem programmatically is to execute it as an external command using `subprocess`, mimicking its typical command-line usage. A more advanced method involves directly calling `ps_mem.main()`, but this requires careful handling of `sys.argv` and `sys.stdout`.
Execute the `ps_mem` command with `sudo` or ensure the script is run with appropriate permissions. For programmatic use via `subprocess`, ensure the command includes `sudo` if necessary, e.g., `subprocess.run(['sudo', 'ps_mem', ...])`.
Only use ps-mem on Linux systems. Consider cross-platform alternatives like `psutil` if OS compatibility is required.
For most programmatic uses, consider running `ps_mem` as a subprocess and parsing its standard output. If direct import is necessary, be prepared to mock `sys.argv` and redirect `sys.stdout`.
Understand that the tool aggregates memory usage by program name, not by individual process IDs, which is a key distinction from other memory reporting utilities like `ps`.
Ensure `ps-mem` is installed via `pip install ps-mem` or by downloading the script and placing it in a directory included in your PATH, such as `/usr/local/bin`, then making it executable: `sudo chmod +x /usr/local/bin/ps_mem`.
Run the `ps_mem` command with `sudo`: `sudo ps_mem`.
Install the package using pip: `pip install ps-mem`. If you intend programmatic use, remember it's primarily a command-line tool, and direct module import might require careful handling; running it as a subprocess is often recommended: `import subprocess; result = subprocess.run(['sudo', 'ps_mem'], capture_output=True, text=True, check=True); print(result.stdout)`.
Create a symbolic link for `python` to point to `python3`: `sudo ln -s /usr/bin/python3 /usr/bin/python`. Alternatively, if running the script directly, explicitly use `python3 ps_mem.py`.
No dependency data recorded yet.