You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 theHttpClient
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 theIHttpClientFactory
.OR make
HttpClient
or anIHttpClientFactory
a static variable shared by the library.OR wrap the
new HttpClient
call in ausing
block.Plus, allow
HttpClient
orIHttpClientFactory
to be passed in as a parameter and managed by the calling application. This is my preference as I have one sharedHttpClient
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)
The text was updated successfully, but these errors were encountered: