Fix memory leak on persistent connections #176
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed a memory leak in my Rails app. The app uses the
searchkick
gem for searching using elasticsearch. That in turn uses thefaraday
gem. I had opted to usehttpx
via it's faraday adapter so I could take advantage of a persistent connection to the elasticsearch server.But recently I started noticing a memory leak in my application. After doing some investigative work on some heap dumps, I started to zero in on httpx, http-2-next, and now after a recent update, http-2.
It is at this point that I should stress: I have no idea what I'm doing. I've made a change here. It makes sense to me, as someone who knows literally nothing about what is required to build or design a working http/2 client. But it seemed like it could be the source of my leak, so I decided to patch it and run it in production on a Friday. 🎉
I'm now about 4 hours in to my inadvisable experiment, and astonishingly nothing seems to have broken. And the memory profile is now flat again!
I have no notion that this PR is worth merging in as is. But I wanted to open it just to say, that I'm fairly confident that there exists a memory leak in the
HTTP2::Connection
class as it is right now. And I'm reasonably confident that this change (however incorrect it is in other ways) seems to fix it, and not immediately cause other problems.Thanks for your work on this gem. I hope this PR helps in some way, even if it isn't by providing mergable code.