I have a Python process that starts leaking memory after a long time (at least 10 hours, sometimes more). The issue is difficult to reproduce, therefore I would like to attach to the running Python Interpreter when the problem comes up and inspect memory usage somehow, e.g. by getting a list of objects that currently allocate the most memory.
This is difficult with the usual profiling tools like tracemalloc or memory-profiler, because they need to be part of the code or started together with the process, and they have a significant impact on runtime performance.
What I would like to have is a sampling profiler that I can simply attach to an existing Python process like py-spy, but py-spy only gives me insights on CPU time spent in functions, not memory usage.
Is there another tool or a different approach that would help me to get insights into the memory usage of an existing Python process?
edit: I just found pyrasite, which provides the pyrasite-memory-viewer command, which is exactly what I'm looking for, but unfortunately the project seems to be abandoned and I can't get it to work on Python 3.8.