Skip to content

Potential memory leak HttpClient/feature enhancement #29

Open
@garie

Description

@garie

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)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Potential memory leak HttpClient/feature enhancement · Issue #29 · edsnider/latestversionplugin