python代码内存使用情况

逐行分析python代码的内存使用情况

# -*- coding:utf-8 -*-
# /usr/bin/python
'''
-------------------------------------------------
   File Name   :  learning
   Description :  AIM:这是一个python模块,用于监视进程的内存消耗以及逐行分析python程序的内存消耗。
                  Functions: 1. 
                             2. 
   use   : python -m memory_profiler learning.py
   Envs        :  python == 
                  pip install  
   Date        :  2020/9/7  18:36
   CodeStyle   :  规范,简洁,易懂,可阅读,可维护,可移植!
-------------------------------------------------
   Change Activity:
          2020/9/7 : tag
-------------------------------------------------
__Author__ = "Yan Errol"
__Email__ = "[email protected]"
__Copyright__ = "Copyright 2020, Yan Errol"
-------------------------------------------------
'''
from memory_profiler import profile
@profile
def my_func():
    a = [1] * (10 ** 6)
    b = [2] * (2 * 10 ** 7)
    del b
    return a

if __name__ == '__main__':
    my_func()
    ```

# 结果
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200907184111645.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl8zMjM5MzM0Nw==,size_16,color_FFFFFF,t_70#pic_center)


你可能感兴趣的:(python小工具封装)