Description
Reproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/github-x9pcfz
Hello, I have an application where I make massive use of material components and I found that my application had memory leaks.
I created an empty Angular 8.2.14 application and imported inside some material components that I use to test them. Here is what the application looks like:
Source code here: https://stackblitz.com/edit/github-x9pcfz
For each components I implemented with Selenium a test scenario containing interactions that are repeated 1000 times. Here are the list of interactions for each tested components:
mat-ripple
: Tap theRIPPLE
button.mat-menu
: Tap theOPEN MENU
label and then tapMENU ITEM
in the opened menu to close the menu.mat-slide-toggle
: Tap twiceSLIDE TOGGLE
to switch states.mat-checkbox
: Tap twiceCHECKBOX
to switch states.mat-radio
: Tap twiceRADIO
to switch states.mat-stepper
: Tap three timesNEXT
button to go across the 3 steps.mat-slider
: TapMINUS
button to decrease slider and then tapPLUS
button to increase the slider.
Before testing a component 1000 times, Chromium is restarted with following option: -js-flags=--gc-global=true, --expose-gc=true
in incognito mode.
The test wait 1 second after each tap.
At the end of each iteration, the test record the current JS heap size using window.memory.usedJSHeapSize
.
Each 10 iterations, window.gc()
is performed to force Major Garbage Collector and then the test wait 60 seconds.
(Yes it took 15 hours to run those tests.)
Here the graph we can plot from the heap size for each scenarios:
A more friendly graph with polynomial smoothing:
My goal here is not to make finger pointing, I like Material since it is pretty simple to use. I am opened to any suggestions to make my tests more reliable or to change the way I am using material components.
Expected Behavior
Memory to be stable over time and not increasing.
Actual Behavior
Memory seems to increase for each tested components.
Environment
- Angular: 8.2.14
- CDK/Material: 8.2.3
- Browser(s): Chromium 78.0.3904.108
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10