What is the expected behavior?
Including a mat-select component and opening it in a dialog should not cause memory leaks/DOM nodes increase.
What is the current behavior?
In Angular Material 2 and 5, if mat-select was opened in a dialog (not necessary to select anything), closing the dialog will increase DOM nodes count.
In versions 6 and 7, the DOM nodes count will increase even it the mat-select was not opened.
What are the steps to reproduce?
Versions:
4 - https://angular-material-2-select-leak.stackblitz.io
5 - https://angular-material-5-select-leak.stackblitz.io
6 - https://angular-material-6-select-leak.stackblitz.io
7 - https://angular-material-7-select-leak.stackblitz.io
(the resulting window links, stackblitz edit links below)
- Open the dialog by pressing the button. Open the select menu. Close the dialog.
(versions 6 & 7 do not required the select being opened, will still leak)
- Repeat 1) a couple of times to avoid lazy loading effects.
- Run garbage collector (F12, Memory tab, garbage can icon)
- Memorize DOM nodes count (F12, Performance monitor)
- Do 1), then garbage collect.
- The DOM nodes count will increase in every such action.
Stackblitz editable links:
2 - https://stackblitz.com/edit/angular-material-2-select-leak
5 - https://stackblitz.com/edit/angular-material-5-select-leak
6 - https://stackblitz.com/edit/angular-material-6-select-leak
7 - https://stackblitz.com/edit/angular-material-7-select-leak
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 4, 5, 6, 7; Angular Material 2, 5, 6, 7
Windows 10, Chrome 70, Typescript 3
Is there anything else we should know?
Similar functionality can be achieved with mat-menu component. It does not produce memory leaks in all versions.
A workaround is possible with autocomplete as well,, however in version 6 & 7 it also leaks.
What is the expected behavior?
Including a mat-select component and opening it in a dialog should not cause memory leaks/DOM nodes increase.
What is the current behavior?
In Angular Material 2 and 5, if mat-select was opened in a dialog (not necessary to select anything), closing the dialog will increase DOM nodes count.
In versions 6 and 7, the DOM nodes count will increase even it the mat-select was not opened.
What are the steps to reproduce?
Versions:
4 - https://angular-material-2-select-leak.stackblitz.io
5 - https://angular-material-5-select-leak.stackblitz.io
6 - https://angular-material-6-select-leak.stackblitz.io
7 - https://angular-material-7-select-leak.stackblitz.io
(the resulting window links, stackblitz edit links below)
(versions 6 & 7 do not required the select being opened, will still leak)
Stackblitz editable links:
2 - https://stackblitz.com/edit/angular-material-2-select-leak
5 - https://stackblitz.com/edit/angular-material-5-select-leak
6 - https://stackblitz.com/edit/angular-material-6-select-leak
7 - https://stackblitz.com/edit/angular-material-7-select-leak
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 4, 5, 6, 7; Angular Material 2, 5, 6, 7
Windows 10, Chrome 70, Typescript 3
Is there anything else we should know?
Similar functionality can be achieved with mat-menu component. It does not produce memory leaks in all versions.
A workaround is possible with autocomplete as well,, however in version 6 & 7 it also leaks.