[release/7.0-rc1] Fix leak caused by not disposing the scoped parent service provider #74362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #74261 to release/7.0-rc1
/cc @tarekgh
Customer Impact
In Dependency Injection, when retrieving the IServiceProvider service and disposing it, it will not dispose the parent container which causes a memory leak. Users of HubConnection in SignalR already experienced and reported this issue as indicated in the issue #73832
Testing
Have passed all CI and regression tests. And manually confirmed it fixes the memory leak.
Risk
Fairly low risk. The change started to dispose the Service Provider object that is supposed to be disposed. The break here is minimal as no-one supposes to use this disposed object and even users can use this disposed object to create a Singlton service.