A Python program can leak memory even though the language has garbage collection. A leak in Python is not memory that is lost, it is memory that something still points to, so that it can never be freed. The way to find it is to measure: take a picture of the memory in use, run the suspect code, take another, and see which lines of source account for the difference. The standard library has a tool for that, tracemalloc, and this lesson shows how to use it, and what to look for.
More lessons in Complete Python Programming