Memory leak in httpx (especially under concurrency) #2558
Unanswered
MrNaif2018
asked this question in
Potential Issue
Replies: 2 comments
-
In my case, I am streaming data files via I tried to find the leak via |
Beta Was this translation helpful? Give feedback.
0 replies
-
SSL context setup seems to be able to leak memory. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! It seems like httpx AsyncClient has memory leaks. In production, my app starts at like 60 mb, then grows very quickly up to 150 MB, and continues to grow at a slow rate (so like a week later it can be 400 MB already). My app is using httpx intensively, sending many requests in parallel via asyncio.gather (at least 20 for sure, at max it can reach a hundred or two). The RAM is not cleaned up. When isolating the use case, in an app where I was just sending a http request and nothing else, memory usage also seems to increase. This is easy to see when using asyncio.gather. That's pretty similar to #1893, but I think the case was not investigated properly. When running that bit of code for longer (or when using asyncio.gather), issue shows up instantly
At the beginning of the test, RAM usage is at ~= 30 MB. At the end of the test after like 10 minutes, it is 75 MB.
Script:
httpx testing script
aiohttp testing script
Screenshots somewhere in the middle of the test:


For httpx:
For aiohttp (see that it is steady, though it increases a little bit too which is weird):
Beta Was this translation helpful? Give feedback.
All reactions