python debug view the process and thread and memory leak problems linked to death

1, python debugging tools can be attached to pyrasite python process, open a python command line in this process. And then execute the code inside this.

(Linked to death for this problem is usually due to multi-process and multi-threaded mix caused multiple threads if locked, fork out the process using a fork to create a multi-process single-threaded process is executed, it will only copy in memory For current information, if there is a lock to be acquired by another thread, we fork out the process of this thread is currently in the lock status will only be locked, the child process will lead to re-use this lock time will lead to a deadlock.)

2, for problems linked to death python process, we need to process all the threads to see them stuck in a position where a.

When we entered this process, we can execute the following code to see the process stack frame.

import sys
for threadid,stack in sys._current_frame().items():
    print(threadid,stack)

3, for the memory leak problem, we can use objgraph to see memory leaks for memory leaks caused by python code, we can easily see references relationship was leaking objects.

But for the leak caused by the C code, we usually only see the object type, and can not see the object reference relationship leak. So also ruled out step by step.

Guess you like

Origin www.cnblogs.com/lycsdhr/p/11831788.html