Skip to content
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

[5.0.1] Clear events when DbContext is disposed or returned to the pool #23288

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

ajcvickers
Copy link
Member

@ajcvickers ajcvickers commented Nov 12, 2020

Fixes #23108

Description

We added three new .NET events on DbContext in 5.0. These events are not cleared when the DbContext is disposed, which can lead to memory leaks.

Customer Impact

Potential memory leak. (We had a similar bug in the early days of EF6 that resulted in several hard-to-find customer memory leaks.)

How found

Internal code review.

Test coverage

We were missing coverage for this. Added in this PR.

Regression?

No; these events are new in 5.0.

Risk

Very low. Set the event handlers to null when the context is disposed (and hence it is invalid to use it anymore and any operation on it will call ObjectDisposedException. Also quirked.

@ajcvickers ajcvickers requested a review from a team November 12, 2020 17:29
@ajcvickers ajcvickers added this to the 5.0.1 milestone Nov 12, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.1, 5.0.x Nov 12, 2020
@leecow leecow modified the milestones: 5.0.x, 5.0.1 Nov 12, 2020
@ajcvickers
Copy link
Member Author

Approved by Tactics.

@ajcvickers ajcvickers merged commit 7df99d2 into release/5.0 Nov 13, 2020
@ajcvickers ajcvickers deleted the LeakyRoofLeakyFloor1111 branch November 13, 2020 16:24
@ajcvickers ajcvickers removed this from the 5.0.1 milestone Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants