memory leak?

Gabriel Rossetti gabriel.rossetti at arimaz.com
Tue Dec 9 12:31:37 EST 2008


I have been debugging a distributed application for about 2 days that 
has a memory leak. My app is a Twisted app, so I thought that maybe it 
was on the twisted side, I finally isolated it to no being a Twisted 
problem but a Python problem. The problem comes from the code that uses 
wxPython and pySerial, these each run in a different process. I wrote 
test programs, one "pure" wxPython, one "pure" pySerial and let them 
run. The number of objects in the wxPython code doubles in about an 
hour, the pySerial code doubles about every 10 minutes. I think there is 
something wrong with the GC/memory management or C lib. The wxPython lib 
is big, so it may have bugs, but pySerial is small and pure python (no 
C/C++ directly, event thought it uses os.open/close & termios that 
themselves use C (unless I mistaking)) and I reviewed it's code and I 
see nothing that could cause this.

I ran these tests on linux 2.6 (ubuntu 8.04) using python 2.5.2. I used 
the "ps" command to see the memory usage and also a recipe that I found 
that counts the number of objects. I attached the pyserial, wxPython 
code & the recipe. To test them just run each example and run "ps waux | 
grep python" once in a while, or send the process a SIGUSR1 and it will 
print in the terminal the object count. The wxCode has a refresh 
problem, if you use the SIGUSR1/object count method you have to right 
click on the taskbar icon to have it show up in the terminal.

I hope I wrong and the problem is elsewhere though.

Thank you very much,
Gabriel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_utils.py
Type: text/x-python
Size: 1431 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20081209/0aa8eb17/attachment-0003.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyserial_meme_leak_test.py
Type: text/x-python
Size: 627 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20081209/0aa8eb17/attachment-0004.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wxPythonTaskBarTest3.py
Type: text/x-python
Size: 4487 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20081209/0aa8eb17/attachment-0005.py>


More information about the Python-list mailing list