Finding Memory Leaks in Python with tracemalloc
A process that grows from 200 MB to 2 GB over a weekend is rarely a mystery you can solve by staring at code. You need to know which line allocated the memory that is still alive. Python ships with a tool for exactly that: tracemalloc.
It is not a profiler for speed, and it is not a replacement for heap analyzers. It answers one narrow, useful question: which Python allocation sites are responsible for the memory currently held?
Why process RSS misleads you
Operating-system memory includes the interpreter, shared libraries, allocator fragmentation, and memory that Python has freed but not returned to the OS. Watching RSS can tell you that something is wrong; it cannot tell you where.