memory-profiler
A module for monitoring memory usage of a python program
What it is and what it does
Memory Profiler is a Python module for analyzing memory consumption at both the process level and the line-by-line level within functions. It provides two main modes: line-by-line profiling (via the @profile decorator or -m memory_profiler flag) that shows memory usage and increments for each line of code, and time-based profiling (via the mprof command-line tool) that records overall memory usage over time and can generate plots. It depends on psutil for system-level memory monitoring.
The package is designed for developers and researchers who need to understand where memory is being allocated and freed in their Python programs. It can track multiprocessing contexts, plot memory trends, and identify potential memory leaks. However, the package is no longer actively maintained, meaning bug fixes and compatibility updates are unlikely to be forthcoming.
Use it for:
- Identify which lines of code in a function consume the most memory by decorating with @profile and running with -m memory_profiler.
- Track overall memory usage of a long-running Python script over time using mprof run and mprof plot to visualize trends.
- Detect memory leaks by monitoring whether memory usage grows unexpectedly during process execution.
- Profile multiprocessing applications to see memory consumption of parent and child processes separately or combined.
- Generate memory usage reports with plots for performance analysis and documentation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Profiles memory consumption line-by-line in Python functions and tracks overall process memory usage over time using the psutil module.
Yes, with caution. The package is stable and widely used (top 5000 PyPI), has low install friction, and carries no known vulnerabilities. However, it is dormant with no active maintenance. Install it if you need line-by-line memory profiling and can accept that bugs or compatibility issues will not be fixed by the maintainer. Consider it a mature, read-only tool rather than an actively developed project.
Install
memory-profiler on PyPI
pip
pip install memory-profileruv
uv add memory-profilerpoetry
poetry add memory-profilerInstalling memory-profiler
Before you install
Low install friction with a single runtime dependency (psutil). However, the package is dormant—last release was 2022-11-15 and the maintainer has stated it is no longer actively maintained and issues will not be actively addressed.
License in practice
BSD license (permissive) allows use in most projects without significant restriction, though you should review the specific BSD terms if proprietary use is involved.
Quickstart
pip install memory-profiler
from memory_profiler import profile
@profile
def my_func():
a = [1] * (10 ** 6)
return a
if __name__ == '__main__':
my_func()
# Run with: python -m memory_profiler script.py
Requires Python 3.5 or later; psutil must be installed as a runtime dependency.
Verify before relying
- Whether the package works reliably with recent Python versions given the dormant maintenance status.
- Current compatibility with modern versions of psutil and any plotting dependencies.
- Whether multiprocessing and child-process tracking features remain functional in current environments.
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — psutil |
| Maintenance | dormant — 1,368 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,236,074/month — #1,643 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: memory_profiler-0.61.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
line-profilerline_profiler measures execution time on a…
permissive · top 5,000 on PyPI
ps-memps_mem reports the actual core memory usage…
copyleft · top 5,000 on PyPI
py-spypy-spy is a sampling profiler that attaches to…
permissive · top 1,000 on PyPI
scaleneScalene profiles Python code to measure CPU,…
permissive · top 15,000 on PyPI
pyroscope-ioPyroscope-io is a continuous profiling agent…
permissive · top 5,000 on PyPI
pytest-monitorA pytest plugin that automatically measures and…
permissive · top 15,000 on PyPI
pyinstrumentPyinstrument is a statistical call-stack…
permissive · top 5,000 on PyPI
psutilpsutil retrieves real-time information about…
permissive · top 1,000 on PyPI
memrayMemray is a memory profiler for Python that…
permissive · top 5,000 on PyPI
PySnooperPySnooper is a decorator-based debugging tool…
permissive · top 15,000 on PyPI