-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scoped ServiceProvider not releasing disposing HttpClient #96296
Comments
Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection Issue DetailsDescriptioni have spent some time narrowing this down to the smallest reproducible example basically when using ' using (var scope = s.ServiceProvider.CreateScope())' im expecting that anything created in this scope is disposed when the scope is ended.. this does not seem to be the case for Typed HttpClients, where you register the client with 'AddHttpClient' my testing it looks like its only disposed of when some internal 2min for holding on the to HttpCleint has been reached. there should be no more references to the scoped context once disposed.
Reproduction Steps
mem should not be climbing all the time.... Expected behaviorthe scoped service and all of its services should be completely disposed... including type clients Actual behaviorscoped service hangs around until the typed client starts its internal cleanup like 2min later Regression?No response Known Workaroundsdont know of any ConfigurationNo response Other informationNo response
|
Instead, HttpClientHandlerOptions.HandlerLifetime is used to determine how long a handler can be reused. As you are seeing, it defaults to 2mins |
how do i allow my scope to control lifetimes |
looks like its simular... come about for me as i try to test plugins and releasing of them.. it will not and its not clear why... its the code hanging on to instance via the underlying stuff of the factory stuffs which its not disposabled even tho the scope is simplicity told its finished.. this does not respect that scope. |
@SeeBizkit can you clarify -- if #47091 is addressed, what work is expected to still need to be done? Thanks |
This issue has been marked |
@steveharter well my understanding is they are basically the same thing, [could be wrong] my issue is there is currently no way to actually control this that im aware of or could find, [well im hoping for alternative] aka how would i code for this... if the answer is #47091 is addressed, then fair enough. otherwise am i missing something and this can actually be configure in such way that the scope is the scope. if 47091 does not actually resolve this then, part of 47091 should be that this functionality behaves in such a way that one would expect. as this is cause issue when trying to debug memory leaks and the likes.. |
@CarnaViire is this issue can be handled with #47091? if so, we could close this as dup |
Yes, I confirm this is a dup of #47091 |
Description
i have spent some time narrowing this down to the smallest reproducible example
consider the below...
basically when using ' using (var scope = s.ServiceProvider.CreateScope())' im expecting that anything created in this scope is disposed when the scope is ended..
this does not seem to be the case for Typed HttpClients, where you register the client with 'AddHttpClient'
my testing it looks like its only disposed of when some internal 2min for holding on the to HttpCleint has been reached.
there should be no more references to the scoped context once disposed.
Reproduction Steps
GC.Collect(); GC.WaitForPendingFinalizers();
mem should not be climbing all the time....
Expected behavior
the scoped service and all of its services should be completely disposed... including type clients
Actual behavior
scoped service hangs around until the typed client starts its internal cleanup like 2min later
Regression?
No response
Known Workarounds
dont know of any
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: