[Twisted-Python] Twisted client memory leak
diego at woitasen.com.ar
Tue Jan 22 08:54:27 EST 2013
On Tue, Jan 22, 2013 at 10:38 AM, Marco Giusti <marco.giusti at gmail.com> wrote:
> On Tue, Jan 22, 2013 at 10:18:13AM -0300, Diego Woitasen wrote:
>> Here is the server code if you want to have a test:
>> On Tue, Jan 22, 2013 at 10:06 AM, Diego Woitasen <diego at woitasen.com.ar> wrote:
>> > I have an Twisted client app that makes hundreds of connections per
>> > minute. I discover that I have a memory leak un my app and I'm almost
>> > sure that is related to the ClientFactory() derived class that is
>> > never deleted.
>> > I reproduce the problem with a modification of Echo client example
>> > from Twisted documentation:
>> > With this code I discover that the instances of EchoClientFactory()
>> > are only deleted when the program shutdowns. They are not deleted when
>> > the connections finish. I haven't found in the documentation if I need
>> > to do some to get factory instances deleted.
> Add the following lines and see yourself, the factories are deleted as
> import gc
> def collect():
> lambda s, f: reactor.callLater(0.001, collect)
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
Ok, that's work. Thanks.
My question is now, why is this done automatically for EchoProtocol()
and not for EchoFactory()? Looks like the references are dropped why
Python is taking too much time to frees the memory.
An explanation around this is welcome :)
More information about the Twisted-Python