-
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
Menu: MenuClose - Subscriptions are not cleaned up #14094
Labels
P4
A relatively minor issue that is not relevant to core functions
Comments
crisbeto
added
has pr
P4
A relatively minor issue that is not relevant to core functions
labels
Nov 12, 2018
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Mar 31, 2019
Fixes the `matMenuTrigger` not unsubscribing from its `_menuCloseSubscription`. Also removes a pretty simple private method that was only being used once. Fixes angular#14094.
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
May 13, 2019
Fixes the `matMenuTrigger` not unsubscribing from its `_menuCloseSubscription`. Also removes a pretty simple private method that was only being used once. Fixes angular#14094.
jelbourn
pushed a commit
that referenced
this issue
May 13, 2019
Fixes the `matMenuTrigger` not unsubscribing from its `_menuCloseSubscription`. Also removes a pretty simple private method that was only being used once. Fixes #14094.
RudolfFrederiksen
pushed a commit
to RudolfFrederiksen/material2
that referenced
this issue
Jun 21, 2019
…#15667) Fixes the `matMenuTrigger` not unsubscribing from its `_menuCloseSubscription`. Also removes a pretty simple private method that was only being used once. Fixes angular#14094.
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.
Bug, feature request, or proposal:
If the MatMenuTrigger element is destroyed, the menuClosedSubscription on the MatMenu is not cleaned up which leads to a memory leak as the number of observers is increasing over time.
What is the expected behavior?
The MatMenuTrigger should unsubscribe it's _menuCloseSubscription on the MatMenu in the cleanUpSubscription method
https://github.com/angular/material2/blob/1fb1c5550e426906cef03357b25971aa486d8c68/src/lib/menu/menu-trigger.ts#L453-L456
What is the current behavior?
The _menuCloseSubscription is not unsubscribed in ngOnDestroy() -> _cleanUpSubscriptions(), so the old observer is still bound to the menu which prevents the GC to release the old Observer.
What are the steps to reproduce?
Everytime that the trigger is destroyed and created again, an additional observer is created
https://stackblitz.com/edit/angular-svnkjn?file=src%2Fapp%2Fapp.component.ts
What is the use-case or motivation for changing an existing behavior?
Can lead to massive memory leaks in some use cases
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 7.0.3, Windows 10, Typescript 3.1.1
Is there anything else we should know?
It seems like the bug was introduced with this commit: fc5f5d3
This topic came up during commit discussions:
But in the case that only the MatTrigger is destroyed and the Panel still exists - the close stream is not completed
The text was updated successfully, but these errors were encountered: