memory_profiler使用
memory_profiler主要用来监控python工程占用内存大小
安装
pip install -U memory_profiler
用法
from memory_profiler import profile
在需要分析的函数上面添加注释
@profile(precision=4,stream=open('memory_profiler.log','w+'))
查看memory_profiler.log
,里面记录了每一行代码的内存使用情况