latestversionplugin icon indicating copy to clipboard operation
latestversionplugin copied to clipboard

Potential memory leak HttpClient/feature enhancement

Open garie opened this issue 4 years ago • 0 comments

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)

garie avatar Aug 22 '20 12:08 garie