I was attempting to figure out where the leaks are in piglet using tracemalloc, following this tutorial. I’ve previously tried using other lower-level implementations including simply keeping track of objects in gc or using a package pympler that recursively gets the size of all objects in memory, but those did not yield results, as demonstrated in 2023-12-21.

With tracemalloc, I was able to get some traces, but none of them point to the huge RAM that the Python program is occupying. It might be just that the arena is not yet released under the hood—I read that Python may still hold on to those memory from the system even if it doesn’t need them (yet). It will only release it once the entire arena is cleared.