DanisHack / rtmplite

Automatically exported from code.google.com/p/rtmplite
0 stars 0 forks source link

Memory leak in siprtmp and rfc3261.py #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Reported by Łukasz Paszke <lukasz.paszke@implix.com> May 6, 2010

Hi,

Thank you for p2p-sip.

I am debugging memory leaks in siprtmp.py from rtmplite, and sipd.py from 
p2p-sip. siprtmp.py and sipd.py are based on p2p-sip. I know that in sip.py 
memory usage increases after every register request generated by asterisk 
1.4.22 on reregistration. This is because ServerTransaction and Proxy objects 
are not closed (removed from memory) after each successful register 
transaction. Therefore there is a buildup in the number of this object over 
time (40 MB over 4 days).

Can you advise what can be wrong and where to look for the solution in the code?

Best Regards / Pozdrawiam

Łukasz

---

I can try looking at the memory problem in rfc3261.py file.
There is a circular reference among transaction and Dialog/Proxy
object I feel. I think I had implemented a close() method in both the
classes. But may be the close() method is not getting invoked for
cleanup on the Proxy object.

Which tool are you using to detect the memory leak?

We can probably chat further on gtalk (kundan10@gmail.com) and nail
this down....

---

I use pdb and objgraph from 
http://www.lshift.net/blog/2008/11/14/tracing-python-memory-leaks

I am new to python (I have experience in ruby, a little bit like python).

I think the problem occurs because of typo in rfc3261.py. Please see 
rfc3261.py.patch for more details. After this correction objects are correctly 
destroyed during registers/reregisters with asterisk.

I found some other leak occurring every time siprtmp.py registers/reregisters 
to sipd.py (increase in application memory consumption), but unfortunately I 
cant find any application objects in memory space after application termination.

siprtmp.py also have a number of more complicated memory leaks.

---

Index: rfc3261.py
===================================================================
--- rfc3261.py  (revision 917)
+++ rfc3261.py  (revision 918)
@@ -560,7 +560,7 @@
    def state():
        def fset(self, value):
            self._state = value
-            if self._state == 'terminating': self.close() # automatically 
close when state goes terminating
+            if self._state == 'terminated': self.close() # automatically close 
when state goes terminating
        def fget(self): return self._state
        return locals()
    state = property(**state())

---

Hi Lukasz,

Thanks for the patch. That was a tricky typo and thanks for detecting.

We will add the memory leak detection as our things to do. I agree
that siprtmp.py is pretty primitive -- it was a student project and
haven't been regressed for robustness.

Regards

Original issue reported on code.google.com by voiprese...@gmail.com on 3 Feb 2011 at 11:21

GoogleCodeExporter commented 9 years ago
Applied the patch in p2p-sip's rfc3261.py in version 1.9 of the source 
distribution.

Original comment by voiprese...@gmail.com on 3 Feb 2011 at 11:21