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

  • 相关阅读:
    C#异步调用的好处和方法
    asp.net运行原理
    基于jQuery的AJAX和JSON的实例
    Slq Server创建索引
    SQL查询一个表中类别字段中Max()最大值对应的记录
    优化SQL Server的内存占用之执行缓存
    ASP.NET缓存
    .NET Framework 4.5新特性
    ADO.NET 连接数据库字符串(Oracle、SqlServer、Access、ODBC)
    sql server基础
  • 原文地址:https://www.cnblogs.com/shengulong/p/8044132.html
Copyright © 2011-2022 走看看