[Twisted-Python] Twisted client memory leak

Marco Giusti marco.giusti at gmail.com
Tue Jan 22 08:38:10 EST 2013

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:
> Thanks!
> 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)


More information about the Twisted-Python mailing list