Hi everyone,
First of all, I would like to thank for such a useful tool for debugging
memory issues. I am pretty proud as a Python lover that we have such a
tool: tracemalloc:)
I would like to ask if something is feasible/practical regarding
tracemalloc:
AFAIU, tracemalloc holds a single traceback per-object:
Example:
class A:
def __init__(self):
self._d = []
def alloc(self):
self._d += [1] * 512
def alloc_more(self):
self._d += [1] * 512
tracemalloc.start(25)
a = A()
a.alloc()
a.alloc_more()
stats = tracemalloc.take_snapshot().statistics('traceback')
for t in stats:
print(t)
print(t.traceback.format())
"""
Output:
...
5.py:38: size=9264 B, count=1, average=9264 B
[' File "5.py", line 38', ' a.alloc_more()', ' File "5.py", line 32',
' self._d += [1] * 512']
"""
Now, allocation of alloc and alloc_more functions seems to be merged into a
single traceback. Is it possible we add (maybe a constant number of
tracebacks) per object? This might be pretty useful to find the responsible
leak in situations where same object is modified in many places?
I have been playing with this module only lately on tracemalloc, so please
correct if a major piece is missing in my example or my understanding is
wrong in some way.
Thanks as always!
--
Sümer Cip
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/GLTOV6CV5AGM465CFSRSZHIVU7R4436G/
Code of Conduct: http://python.org/psf/codeofconduct/