zoukankan      html  css  js  c++  java
  • 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 <PID>
    $ 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

  • 相关阅读:
    计算机基础总结
    Apache安装错误 APR not found解决方法
    一、编译错误
    2.2 进程控制之进程共享
    2.1 进程控制之fork创建子进程
    ARM串口控制终端命令
    u-boot、kernel、root系统烧写和挂载命令命令
    8.1 编写USB鼠标驱动程序,并测试
    八、USB驱动分析
    Source Insight的使用
  • 原文地址:https://www.cnblogs.com/shengulong/p/8044132.html
Copyright © 2011-2022 走看看