使用memory_profiler工具对python工程做内存分析

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,里面记录了每一行代码的内存使用情况

猜你喜欢

转载自blog.csdn.net/qq_30262201/article/details/101905086