Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#21 closed defect (invalid)

Memory leaks using a modified session

Reported by: ftputiluser Owned by: schwa
Priority: major Milestone: never
Component: Library Version: 2.0.1
Keywords: memory leak, reference count Cc: antonio.beamud@…


If you create a modified session, for example, to specify a port to connect... You create a connection with this session and you try to do a list_dir, for example, if this operation fails, you catch the exception but the session object increments its reference counting and cannot be deleted by the garbage collector... Every time you do this operation in a loop and the exception is raised, the reference grows... The code should be something like:

class MySession:
 def __init__(self, host, port, user, passwd):
        self.connect(host, port)
        self.login(user, passwd)

 self.conn = ftputil.FTPHost(m,
 del self.conn

Change History (3)

comment:1 Changed 12 years ago by schwa

Keywords: memory leak reference countmemory leak, reference count
Status: newassigned

Hello Antonio,

Thanks for your bug report - but I need more information. ;-) I can't see how the garbage collecting should be different when you use the default ftplib.FTP for the session_factory or a derived class, as long as the derived class doesn't contain bugs related to memory management.

The second thing is that ftputil is pure Python code, so at least I wouldn't expect bugs due to reference counting on the C/Python API level. I know of possible problems in the garbage collection even if only Python code is involved, however, ftputil 2.2.2 contains only one __del__ method (in FTPHost).

I recommend two things:

  • Please try your problematic code with the latest ftputil version. Your bug report states to be for version 2.0.1, which is quite old.
  • If the problem still persists, please attach a small example program to this issue which reproduces the problem. (Of course, you should remove all confidential information, such as user id or password.) You may use the debugging functionality of the gc module to show that there's memory which can't be freed.

comment:2 Changed 12 years ago by schwa

Resolution: invalid
Status: assignedclosed

I now set this bug's resolution to "invalid". There may be a bug, but I still need more information to reproduce it, if that's possible. If you still have problems regarding this issue, please reopen it.

comment:3 Changed 10 years ago by schwa

Milestone: never
Note: See TracTickets for help on using tickets.