-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix leak caused by not disposing the scoped parent service provider #74261
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,8 +189,11 @@ static async ValueTask Await(int i, ValueTask vt, List<object> toDispose) | |
|
|
||
| } | ||
|
|
||
| if (IsRootScope) | ||
| if (IsRootScope && !RootProvider.IsDisposed()) | ||
| { | ||
| // If this ServiceProviderEngineScope instance is a root scope, disposing this instance will need to dispose the RootProvider too. | ||
| // Otherwise the RootProvider will never get disposed and will leak. | ||
| // Note, if the RootProvider get disposed first, it will automatically dispose all attached ServiceProviderEngineScope objects. | ||
| RootProvider.Dispose(); | ||
tarekgh marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why cant this just noop internally?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is simpler. no? More code, more bugs :-) imagine in the future we add anything to the ServicePrivder dispose method.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
By "just noop internally", you mean adding the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. |
||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.