[Python-Dev] refleaks on trunk (original) (raw)

Amaury Forgeot d'Arc amauryfa at gmail.com
Tue Apr 1 09:37:12 CEST 2008


On Tue, Apr 1, 2008 at 6:34 AM, Neal Norwitz <nnorwitz at gmail.com> wrote:

testio is the only leaky test on trunk that I know of. I narrowed down the leaks to the code below.

It's possible there are other leaks in testio. n -- import sys, gc import fileio, io class FileIO(fileio.FileIO, io.RawIOBase): def close(self): io.RawIOBase.close(self) def main(): class MyFileIO(FileIO): pass f = MyFileIO('tt-test', "w") f.close() for i in range(10): main() print(gc.collect()) print(sys.gettotalrefcount())

The problem is that the MyFileIO class is registered in io.RawIOBase._abc_cache, and never freed. This is a problem with ABCs: _abc_cache should be changed to a WeakSet, like python3.0 did.

I filed http://bugs.python.org/issue2521 about this problem.

-- Amaury Forgeot d'Arc



More information about the Python-Dev mailing list