Closed GoogleCodeExporter closed 9 years ago
Before the memory leak I get an IOError: [Errno 24] Too many open files.
After setting the number of open files to unlimited I can reproduce the issue.
I think both things may be related.
Original comment by useboxnet
on 13 Jun 2013 at 7:53
I forgot:
pyftpdlib 1.2.0
Python 2.7.3
Ubuntu 12.04 (Precise) x86_64
I can reproduce the problem in Debian Sqeeze with Python 2.6.6.
Original comment by useboxnet
on 13 Jun 2013 at 8:07
I've found the file descriptor leak, but it didn't fix the memory leak I'm
afraid.
I'm attaching a patch, I hope it helps. Please read it for details.
Thanks!
Original comment by useboxnet
on 13 Jun 2013 at 11:11
Attachments:
Ah, the patch doesn't work with the thread based server. Besides the descriptor
leak is not present in the threaded server because there's not fork() (and the
descriptor is not duplicated).
I've attached a new patch.
You may wan to implement it in a different way but because the task needs to
start before we can release resources in the main process, I've used the pid
attribute of Process (not available in Thread) to detect if a process was
spawned.
Original comment by useboxnet
on 13 Jun 2013 at 12:10
Attachments:
I've found the memory leak!
_SpawnerBase._active_tasks grows forever. The _active_tasks.remove in
_SpawnerBase._loop won't work with the multiprocessing server because is being
run in a different process.
The attached patch fixed the issue by removing the finished tasks before adding
a new one *in the main process* (instead of delegating it to one of the
spawned tasks).
Includes the file descriptor leak fix (may not be a good idea but it is a 3
lines patch).
Regards,
Juan
Original comment by useboxnet
on 13 Jun 2013 at 1:00
Attachments:
Oh, It really works. Thank you very much!
Original comment by timebug....@gmail.com
on 13 Jun 2013 at 1:15
[deleted comment]
I patched pyftpdlib in our production systems but I'd be nice to see this fixed
as it's being used by other projects (such as ftpcloufs) and these are two
pretty bad leaks :)
EDIT: re-post, sent the previous comment by mistake
Original comment by useboxnet
on 16 Jul 2013 at 1:28
Sorry for replying so late, at the time this was first submitted I was
traveling and then I forgot about this issue.
Juan I committed your patch as as of r1229.
I hope I will be able to produce a new release soon as this is kind of high
priority.
Original comment by g.rodola
on 16 Jul 2013 at 2:31
Thanks a lot Giampaolo.
Original comment by useboxnet
on 16 Jul 2013 at 2:35
Original comment by g.rodola
on 8 Nov 2013 at 7:52
Original issue reported on code.google.com by
timebug....@gmail.com
on 12 Jun 2013 at 1:59Attachments: