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

fix(cdk/overlay): avoid leaking memory through afterNextRender #29709

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Sep 9, 2024

The OverlayRef was triggering an afterEachRender and passing in an EnvironmentInjector. Under the hood this uses a DestroyRef that is never destroyed, because the EnvironmentInjector is almost never destroyed.

These changes add an explicit destroy call to avoid the issue.

Fixes #29696.

@crisbeto crisbeto added target: patch This PR is targeted for the next patch release merge: preserve commits When the PR is merged, a rebase and merge should be performed labels Sep 9, 2024
@crisbeto crisbeto requested a review from a team as a code owner September 9, 2024 09:00
@crisbeto crisbeto requested review from amysorto and andrewseguin and removed request for a team September 9, 2024 09:00
The `OverlayRef` was triggering an `afterEachRender` and passing in an `EnvironmentInjector`. Under the hood this uses a `DestroyRef` that is never destroyed, because the `EnvironmentInjector` is almost never destroyed.

These changes add an explicit `destroy` call to avoid the issue.

Fixes angular#29696.
@crisbeto crisbeto removed the merge: preserve commits When the PR is merged, a rebase and merge should be performed label Sep 9, 2024
@crisbeto crisbeto changed the title Resolve a couple of leaks in the overlay fix(cdk/overlay): avoid leaking memory through afterNextRender Sep 9, 2024
@HyperLife1119
Copy link

HyperLife1119 commented Sep 10, 2024

Off-topic: I found a more attractive name here: afterEachRender, which is really more intuitive and clearer than afterRender :)

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Sep 10, 2024
@crisbeto crisbeto merged commit 3a62ab1 into angular:main Sep 10, 2024
23 of 24 checks passed
crisbeto added a commit that referenced this pull request Sep 10, 2024
The `OverlayRef` was triggering an `afterEachRender` and passing in an `EnvironmentInjector`. Under the hood this uses a `DestroyRef` that is never destroyed, because the `EnvironmentInjector` is almost never destroyed.

These changes add an explicit `destroy` call to avoid the issue.

Fixes #29696.

(cherry picked from commit 3a62ab1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(MatMenu): Memory Leak in MatMenu and MatAutocomplete
3 participants