[Yum-devel] possible leak in yum.YumBase()?

Paolo Abeni paolo.abeni at gmail.com
Thu Jun 10 12:50:40 UTC 2010


Hello,

While tracing a memory leak in a simple python program using the yum
API, I find a possible memory leak in the YumBase constructor;
apparently a reference to the newly constructed YumBase instance is
created in yum.packages.base by yum.depsolve.Depsolve.__init__(), and
this reference forbid the YumBase destructor to be called on said
instance.

The following code fragment show the issue:

import yum
import gc

def test():
        yum.YumBase()

def search(msg):
        print msg
        for o in gc.get_objects():
                 if type(o).__name__ == 'YumBase':
                        print str(o)
search('before creation')
test()
search('after creation')
yum.packages.base = None
search('after base = None')

A YumBase instance exists after the call to the test() function, and
it's destroyed after the yum.packages.base = None assignment. Is this
behavior the expected one?
BTW at most a YumBase instance is "leaked" regardless the number of
yum instances created, but I think it can eat a lot of memory,
depending on the repos/sacks contents.

Thank you for any feedback,

Paolo


More information about the Yum-devel mailing list