Memory Profiler
lastmod 2026-11-10created 2021-05-153 edits
memory-profiler is a module that measures the memory usage of Python programs. If you add the @profile decorator to a function and run it with python -m memory_profiler, it prints, line by line, the memory usage and increment as each line runs, and the mprof command can record memory changes over time and plot them as a graph. It is used to find which code causes memory leaks or excessive allocation, and uses psutil internally.
A module for monitoring memory usage of a python program