Python memory profiler

From wikinotes

Profile your python script by running it on commandline.
Set target function with @profile and execute with python -m memory_profiler file.py.

Documentation

github https://github.com/pythonprofilers/memory_profiler

Install

sudo pip install memory_profiler

Usage

@profile
def foo():
    a = 1
    b = 2
python -m memory_profiler example.py