-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Using DI with Razor Components lead to holding on to resources for long times #7396
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
Comments
Thanks for contacting us, @matthewDDennis. |
Seems related: #5496 |
@matthewDDennis, you're right about scoped services to use resources throughout the lifetime of the connection, so it's important to be mindful about the usage of those resources. |
Related: aspnet/Blazor.Docs#400 |
@matthewDDennis as @vertonghenb has already written you should use Warning: you should get your context in a function and assign it to local variable in that function. Don't use automatic constructor injection and don't assign |
If I understand the way DI is used in Razor Components, Scoped services have a lifetime of the connection.
Wouldn't this, especially in the case of DbContexts, leave a lot of resources alive for long times and result in resource, such as SQL connections, or memory starvation if there are MANY concurrent requests?
The text was updated successfully, but these errors were encountered: