-
Notifications
You must be signed in to change notification settings - Fork 419
Memory leak with Pool usage #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Possibly #955? |
Hi there,
I created a repository to reproduce the memoryleak we experience too. With every request the memory steadily increases. We use asyncpg in combination with sqlalchemy. We did not observe an increase of connections to the database, so connection pool reuses connections but leaks memory somewhere else. https://github.com/stollero/async-alchemy-memoryleak |
I appear to have the same problem. I ran tracemalloc in production and this line stood out: /usr/local/lib/python3.13/site-packages/asyncpg/connection.py:470: size=916 KiB (+916 KiB), count=14302 (+14302), average=66 B 14302 connection objects seems a bit excessive . |
the issue with a local PostgreSQL install?: no
uvloop?: only asyncio
When we use a Pool, the memory usage of our process keeps increasing slowly with the number of queries. After 1000 queries, it is ~10MB and this increases with the number of queries executed on connections acquired from the pool. This remains after the max_inactive_connection_lifetime has passed with no activity, with explicit garbage collection and even after we close the pool. We can reproduce this with a psutil measurement and observe it in production. When we replace the usage of Pool with our own creation/cleanup of asynpg Connections, the issue dissapears.
Pool created with the following arguments:
The text was updated successfully, but these errors were encountered: