Install memory_profiler with pip,
pip install memory_profiler
Create a test.py,
from memory_profiler import profile
@profile
def my_func():
    a = 2 ** 10
    b = 5 ** 20
    return a, b
if __name__ == "__main__":
    my_func()
and then use memory_profiler to analyze memory,
python3 -m memory_profiler test.py
The result will be like,

    
Top comments (0)