MS HttpClient has internal handler pool, this pool uses weak references and timer to track handler garbage collection. Unfortunately it also captures DI scope while waiting for handler collection. Scope contains a reference to the parent scope and the parent scope contains a reference to the HttpClient instance (because it implements disposable), HttpClient instance obviously has a reference to the handler. As a result handlers are never collected.
Is there any way to exclude HttpClient from disposable objects?
MS HttpClient has internal handler pool, this pool uses weak references and timer to track handler garbage collection. Unfortunately it also captures DI scope while waiting for handler collection. Scope contains a reference to the parent scope and the parent scope contains a reference to the HttpClient instance (because it implements disposable), HttpClient instance obviously has a reference to the handler. As a result handlers are never collected.
Is there any way to exclude HttpClient from disposable objects?