[Twisted-Python] Twisted Memory Leaks & Epoll

Andrew Bennetts andrew-twisted at puzzling.org
Tue May 1 09:38:10 EDT 2007


Matthew Glubb wrote:
[...]
> For the purposes of diagnosing the cause of the leak (C extension,  
> python, twisted, or my code) I have removed external library  
> dependencies and I have also swapped out reactors. The leak persists.

Those are all good steps to take to isolate the problem.

> Does anyone have any good tips for diagnosing leaks under twisted?  

Basically, the same as for any other long-lived Python program:

  * try to find a minimal case that reproduces the problem, e.g. a simple
    request that leaks some bytes when repeated, or even better a simple
    function call, and hope the cause becomes obvious as you narrow it down
  * try memory profilers like http://pysizer.8325.org/
  * try my crude hack: http://twistedmatrix.com/users/spiv/countrefs.py
  * try to reproduce without any C extensions, to determine if the leak is in a
    C extension or pure python code

-Andrew.





More information about the Twisted-Python mailing list