-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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
force-pushed
the
29696/menu-leak
branch
from
September 9, 2024 11:58
bae0968
to
01a1c5d
Compare
crisbeto
removed
the
merge: preserve commits
When the PR is merged, a rebase and merge should be performed
label
Sep 9, 2024
crisbeto
changed the title
Resolve a couple of leaks in the overlay
fix(cdk/overlay): avoid leaking memory through afterNextRender
Sep 9, 2024
Off-topic: I found a more attractive name here: |
devversion
approved these changes
Sep 10, 2024
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)
crisbeto
added a commit
to crisbeto/angular
that referenced
this pull request
Sep 23, 2024
…ooks Adds a `manualCleanup` flag to `afterRender` and `afterNextRender`, similarly to `effect`. The reason is that currently if the hook is created outside of an injection context, it requires an injector to be passed in. In some cases that injector might be an injector that is never destroyed (e.g. `EnvironmentInjector`) which can give a false sense of security users thinking that the hook will be cleaned up automatically. We fell into this in the CDK which caused a memory leak (see angular/components#29709). With the `manualCleanup` option users explicitly opt into cleaning the hook up themselves.
alxhub
pushed a commit
to angular/angular
that referenced
this pull request
Sep 26, 2024
…ooks (#57917) Adds a `manualCleanup` flag to `afterRender` and `afterNextRender`, similarly to `effect`. The reason is that currently if the hook is created outside of an injection context, it requires an injector to be passed in. In some cases that injector might be an injector that is never destroyed (e.g. `EnvironmentInjector`) which can give a false sense of security users thinking that the hook will be cleaned up automatically. We fell into this in the CDK which caused a memory leak (see angular/components#29709). With the `manualCleanup` option users explicitly opt into cleaning the hook up themselves. PR Close #57917
alxhub
pushed a commit
to angular/angular
that referenced
this pull request
Sep 26, 2024
…ooks (#57917) Adds a `manualCleanup` flag to `afterRender` and `afterNextRender`, similarly to `effect`. The reason is that currently if the hook is created outside of an injection context, it requires an injector to be passed in. In some cases that injector might be an injector that is never destroyed (e.g. `EnvironmentInjector`) which can give a false sense of security users thinking that the hook will be cleaned up automatically. We fell into this in the CDK which caused a memory leak (see angular/components#29709). With the `manualCleanup` option users explicitly opt into cleaning the hook up themselves. PR Close #57917
and-oli
pushed a commit
to and-oli/angular
that referenced
this pull request
Sep 30, 2024
…ooks (angular#57917) Adds a `manualCleanup` flag to `afterRender` and `afterNextRender`, similarly to `effect`. The reason is that currently if the hook is created outside of an injection context, it requires an injector to be passed in. In some cases that injector might be an injector that is never destroyed (e.g. `EnvironmentInjector`) which can give a false sense of security users thinking that the hook will be cleaned up automatically. We fell into this in the CDK which caused a memory leak (see angular/components#29709). With the `manualCleanup` option users explicitly opt into cleaning the hook up themselves. PR Close angular#57917
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
target: patch
This PR is targeted for the next patch release
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.
The
OverlayRef
was triggering anafterEachRender
and passing in anEnvironmentInjector
. Under the hood this uses aDestroyRef
that is never destroyed, because theEnvironmentInjector
is almost never destroyed.These changes add an explicit
destroy
call to avoid the issue.Fixes #29696.