Skip to content
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

Potential memory leak HttpClient/feature enhancement #29

Open
garie opened this issue Aug 22, 2020 · 0 comments
Open

Potential memory leak HttpClient/feature enhancement #29

garie opened this issue Aug 22, 2020 · 0 comments

Comments

@garie
Copy link

garie commented Aug 22, 2020

Feature Request

Description: You are creating a new HttpClient every time a request is made to a server and never disposing it. Best practice is to reuse the HttpClient instance, but if you're not reusing it, it should be disposed.

Suggestions:

Do something like this (adding a LatestVersionPlugin.Init() function that should be called in the app startup) and use the IHttpClientFactory.

OR make HttpClient or an IHttpClientFactory a static variable shared by the library.

OR wrap the new HttpClient call in a using block.

Plus, allow HttpClient or IHttpClientFactory to be passed in as a parameter and managed by the calling application. This is my preference as I have one shared HttpClient in my app, but not all developers will care to manage theirs in the same way so I think it should be optional. Just doing this would fix any potential memory leak so if this is the only change per this issue, I'd be happy.

Docs (sort of - aspnetcore docs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants