mprofile is a low-overhead sampling memory profiler for Python, derived from heapprof, with an interface similar to tracemalloc. It attempts to give results comparable to tracemalloc, but uses statistical sampling to lower memory and CPU overhead. The sampling algorithm is the one used by tcmalloc and Golang heap profilers. The current version is 0.0.15, and it is compatible with Python >= 3.4.
pip install mprofileVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `mprofile`, simulate some memory allocation, take a snapshot of the current memory usage, and print the top memory-consuming lines. The `sample_rate` is set to the recommended 128KB for a balance between overhead and precision.
Use Python 3.4 or newer, or follow the complex manual build process for older Python versions.
Understand that mprofile provides sampled estimates, which are generally sufficient for identifying memory hotspots but may not be suitable for precise memory accounting.
Upgrade to mprofile version 0.0.13 or newer (`pip install --upgrade mprofile`).
Upgrade to mprofile version 0.0.12 or newer (`pip install --upgrade mprofile`).
Upgrade mprofile to version 0.0.13 or newer: `pip install --upgrade mprofile`.
Upgrade mprofile to version 0.0.12 or newer: `pip install --upgrade mprofile`.
Install the package using pip: `pip install mprofile`.
No dependency data recorded yet.