[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#745487: apt python library leak memory and file descriptors



Control: tag -1 pending

On Tue, Apr 22, 2014 at 11:23:24AM +0200, Petter Reinholdtsen wrote:
> 
> Package: python-apt
> Version: 0.8.8.2
> Severity: important
> 
> Since I wrote the isenkram package, it have been plagued with a nasty
> resourse leak.  It leak memory and file descriptors every time some
> hardware is inserted.  The amount of leaked memory varies, but seem to
> be 30-40 MiB every time.  The amount of file descriptors depend on the
> number of APT sources listed in /etc/apt/.
> <URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730704 >
> is an example on what happen when the process run out of file
> descriptors, and
> <URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719837 > is the
> initial report about leaking memory.
> 
> I've been able to track down the problem to the python-apt library, and
> the following test program demonstrate the leak:
> 
>   #!/usr/bin/python
>   import apt
>   while True:
>     cache = apt.Cache()
>     cache.open(None)

Just fixed it in git, expect it to be part of the upcoming
1.0 release.

The problem was that apt.Cache() had a cyclic reference to
itself, because it stored its own methods in its callback
dictionary.

BTW: There is no need to open() the cache, the constructor
already opens it.

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.

Be friendly, do not top-post, and follow RFC 1855 "Netiquette".
    - If you don't I might ignore you.


Reply to: