-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Memory leak in head get requests over SSL #1767
Comments
maybe related to #1756 |
could you check 2.0 branch, I found bug |
nope, still leaking. You can check by yourself with the first script, it only has aiohttp as a dependency and shows |
could you test again with |
not a valid kwarg for TCPConnector, did you mean |
hmm, try this in your script:
|
you can disable connection pool n connector, in that case connections should be released immediately. |
The underlying issue here is a real memory leak: This basic proxy process is leaking around 300 MB of RAM per hour (and this process receives around 1 request per second, and makes 1-2 requests per second to the backend). Currently we're restarting the process regularly to avoid killing our servers… I'll continue investigating the issue, but i don't think the connection pooling or shutdown procedures are part of the issue here: the requests are made relatively slowly, with low concurrency (usually 1, at most 3-5) -- Also, the problem is really specific to HEAD requests, which is very weird i guess. But the exact same script with GET requests does not leak anything: |
interesting, I'll look too |
I can not reproduce the problem with your original scripts.
|
I'm tracking the created objects with objgraph: the aiohttp object leaking are |
do you see other aiohttp related objects? what about asyncio? |
also could you check who holds reference to ResponseHandler object |
I do not see any of aiohttp objects except ResponseHandler, but handler is asyncio protocol try to replace this line https://github.com/aio-libs/aiohttp/blob/2.0/aiohttp/connector.py#L463 |
wait, not replace. but right after "protocol.close()" add "transport.abort()" |
actually, I think all this is a false lead: So everything perfectly normal here. The only weird thing is that this does not happen with GET requests, but this might have something to do with connection pooling done only for GET requests and not for HEAD requests? |
does HEAD request return payload? if it returns any data connector closes connection, on other hand for GET connector can properly detect end of message and can reuse connection. |
The server serving the HEAD requests is aiohttp too, but that's probably it. So this is completely unrelated to memory usage: Here is what i see when I do a HEAD request against a simple aiohttp server:
Is the |
do you return any data inn response? |
aiohttp.web does not prevent you from writing body in response for HEAD |
Ok, I understand what's happening here:
|
yes, this needs come cleanup in 2.1 |
ok. I'll open another issue to track this, and close this, nothing wrong with the memory handling here (my memory leak must be somewhere else, I'll keep looking…) |
good |
I'm trying to track down a memory leak but I not having much luck… Could you have a look?
Here is the leaking code:
I'm using this https server to test:
The first script leaks around 30ko of RAM for every requests (between 8ko and 60ko)
From what i see with objgraph / pympler, the leaking object are
ResponseHandler
s. Not sure why they aren't garbage collected though.The text was updated successfully, but these errors were encountered: