Abdul-Munim
Posted on September 16, 2024
ps_mem: A Lightweight Tool for Accurate Memory Usage Reporting
Are you looking for a reliable way to measure the memory footprint of your programs on Linux? Look no further than ps_mem! This simple Python script provides an accurate view of a program's in-core memory usage.
What it Does
ps_mem goes beyond the basic memory information provided by tools like ps
. It delves into the /proc
filesystem to extract a more precise picture of memory consumption, including:
- Resident Set Size (RSS): The amount of physical memory a process actively uses.
- Shared Memory: Memory shared with other processes. This helps identify potential memory optimization opportunities.
Key Features
- Accuracy: ps_mem leverages the
/proc/$pid/smaps
file for more accurate memory reporting compared to traditional methods. - Lightweight: Being a Python script, ps_mem is easy to install and use, with minimal resource overhead.
- Informative Output: ps_mem displays memory usage in human-readable units (KiB, MiB, etc.) for easy comprehension.
- Process Counting: It also reports the number of processes with a specific name, aiding in identifying resource-intensive applications.
Getting Started
ps_mem is available on GitHub: https://github.com/pixelb/ps_mem
Installation:
- Ensure you have Python 3 installed.
- Clone the repository:
git clone https://github.com/pixelb/ps_mem.git
- Navigate to the project directory:
cd ps_mem
- Run the script:
python ps_mem.py
Going Further
ps_mem offers a straightforward approach to memory analysis.
- For detailed information on script functionality, refer to the commit history: https://github.com/pixelb/ps_mem
- If you're comfortable with Python, consider contributing to the project's development!
For a deeper dive into memory management, explore tools like top
and htop
for real-time monitoring, or consider profiling tools for a more comprehensive analysis.
Posted on September 16, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 24, 2024