Memory not being released by httpx #2414
-
|
I've been spending a bit of time this week hunting down a memory leak. I'm able to reliably produce this now with a few lines of code, and it seems to be related to httpx. I've run some tests using memory_profiler comparing aiohttp and httpx to ensure that what I was expecting to see is valid. aiohttp does not exhibit the same problem. The code (comment/uncomment each section to compare): For the version using httpx, memory profiler shows me: The memory for the variable html holding the response is not freed. Maybe I'm doing something wrong? Edit: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Digging further and extending my test, I see that over time memory does get freed and there is no memory leak here (It levels out after just a few requests as can also be seen here #1893) Code below: |
Beta Was this translation helpful? Give feedback.
Digging further and extending my test, I see that over time memory does get freed and there is no memory leak here (It levels out after just a few requests as can also be seen here #1893)
The test below requests a 100kb file, 300 times and then measuring the amount of memory used.
After 300 requests, there is an overall memory increase of only ~5mb in my tests.
Code below: