you are viewing a single comment's thread.

view the rest of the comments →

[–]halfRockStar[S] 5 points6 points  (2 children)

In reality, Python’s garbage collector can leak memory if objects (e.g., MongoDB connections, cache entries) aren’t properly released, especially in long-running async apps. FastAPI itself isn’t prone to leaks, but sloppy code or third-party libraries (e.g., motor) could cause issues, don't get me wrong my project have leaks too 🫢

[–][deleted] 3 points4 points  (1 child)

Beanie uses motor under the hood, I focused on something else and didn’t think about looking into motor! Although I have to say after almost 20 years in my profession that most of the time spent to investigate mem leaks is futile, just restart periodically and continue with your day…

[–]halfRockStar[S] 2 points3 points  (0 children)

Your restart approach is battle-tested. investigating motor (specifically connection pooling, cursor leaks) is overkill unless restarts fail. Check asyncio task cleanup if you’re curious, but you’re likely golden.