I am working on a WebCrawler implementation but am facing a strange memory leak in ASP.NET Web API\'s HttpClient.
So the cut down version is here:
The default HttpClient
leaks when you use it as a short-lived object and create new HttpClients per request.
Here is a reproduction of this behavior.
As a workaround, I was able to keep using HttpClient as a short-lived object by using the following Nuget package instead of the built-in System.Net.Http
assembly:
https://www.nuget.org/packages/HttpClient
Not sure what the origin of this package is, however, as soon as I referenced it the memory leak disappeared. Make sure that you remove the reference to the built-in .NET System.Net.Http
library and use the Nuget package instead.