python 类变量 none 内存泄露_python内存泄露诊断过程记录pyrasite

工具:pyrasite;包含三个命令行 pyrasite / pyrasite-shell / pyrasite-memory-viewer

安装:gdb meliae urwid

说明:Pyrasite is a library and a set of tools for injecting code into running Python programs.

1、使用:pyrasite -l 显示可以使用的脚本,脚本路径在:/usr/local/lib/python2.7/site-packages/pyrasite/payloads

脚本helloworld.py的作用,是在运行的进程里打印出helloworld字段

2、使用命令pyrasite-memory-viewer pid查看当前进程的最大对象

退出:q 然后出现下图后y

3、使用命令pyrasite-shell pid进入进程的shell,然后可以使用globals()和locals()查看全局和本地变量

pyrasite-shell - Give it a pid, get a shell

You can easily drop into a shell and execute commands in a running process using the pyrasite-shell.

$ pyrasite-shell

Usage: pyrasite-shell

$ pyrasite-shell $(pgrep -f "ipython")

Pyrasite Shell 2.0beta9

Connected to 'ipython'

Python 2.7.2 (default, Oct 27 2011, 01:40:22)

[GCC 4.6.1 20111003 (Red Hat 4.6.1-10)] on linux2

>>> print(x)

foo

>>> globals()['x'] = 'bar'

工具:lptrace,跟踪进程

安装:pip install lptrace

参考:

1、http://pyrasite.com/

2、https://github.com/khamidou/lptrace

3、http://pyrasite.readthedocs.io/en/latest/#

4、https://www.mankier.com/1/pyrasite#Contents-pyrasite-memory-viewer_-_View_the_largest_objects_in_your_process

5、http://www.jianshu.com/p/2d06a1a01cc3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值