[issue33565] strange tracemalloc results

STINNER Victor report at bugs.python.org
Fri May 18 20:48:38 EDT 2018


STINNER Victor <vstinner at redhat.com> added the comment:

tracemalloc doesn't track memory leaks. It tracks memory allocations.

I'm not sure that you are using tracemalloc properly. I suggest you to enable tracemalloc as soon as possible, take snapshot frequently (eg. at each iteration) and write them on disk, and later compute differences between snapshots.

You may want to try my tracemallocqt UI to analyze snapshots:
http://pytracemalloc.readthedocs.io/tracemallocqt.html

What matters to track a memory leak is to find the largest positive difference.

I don't know what allocated "21 memory blocks: 4.7 KiB" at your "raise" line. tracemalloc tracks *all* memory allocated by Python, including very private internal structures, like the dictionary used for "interned" strings. Sometimes, results can be surprising, but it should be simpler if you focus on differences between two snapshots.

If you have a leak per iteration, after 10 or 25 iterations, the difference should become obvious.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33565>
_______________________________________


More information about the Python-bugs-list mailing list