[issue19816] test.regrtest: use tracemalloc to detect memory leaks?

STINNER Victor report at bugs.python.org
Thu Jun 12 14:48:40 CEST 2014


STINNER Victor added the comment:

I tried different options to show the memory leaks found by tracemalloc, but I'm not satisfied by any option. I get a lot of noise, the output is almost useless. Randomly, between 1 and 1000 KB are allocated or released in random files: in unittest or linecache modules for example.

It looks like the major issue is that the unittest leaks memory. For example, there are still 4 TestCase instances alive after the execution of test_sys. But later, these instances are deleted.

It looks like it creates reference leaks and so memory is only released late. Calling gc.collect() doesn't help. I remember that I already saw something strange with the _Outcome class used in unittest.TestCase.run(). See the issue #19880 (changeset 09658ea0b93d).

The asyncio module has a similar issue: it stores an exception which indirectly contains a reference cycle in the Exception.__traceback__ attribute.
http://bugs.python.org/issue17911
https://code.google.com/p/tulip/issues/detail?id=155

----------
keywords: +patch
Added file: http://bugs.python.org/file35594/regrtest.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19816>
_______________________________________


More information about the Python-bugs-list mailing list