python graphviz下载

https://pypi.python.org/pypi/pygraphviz/

https://pypi.python.org/pypi/Dozer/

https://github.com/wyplay/pytracemalloc

https://pypi.python.org/pypi/memory_profiler

# -*- coding: utf-8 -*-

from memory_profiler import profile

fp=open('memory_profiler.log','w+')
@profile(stream=fp)
def my_func():
    a = [1] * (10 ** 6)
    b = [2] * (2 * 10 ** 7)
    del b
    return a

if __name__ == '__main__':
    my_func()

透过GC看内存

  • Python的gc模块功能还是很强大的
  • 使用get_objects( )方法可以取得当前所有不能回收的对象(引用计数不为0)的列表
  • 存放在列表中的是所有对象的wrapper
原文地址:https://www.cnblogs.com/hxiaoli/p/5405885.html