Skip to content

bug: Memory Leaks on several material components ? #19010

Open
@flemgs

Description

@flemgs

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:

image
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 the RIPPLE button.
  • mat-menu: Tap the OPEN MENU label and then tap MENU ITEM in the opened menu to close the menu.
  • mat-slide-toggle: Tap twice SLIDE TOGGLE to switch states.
  • mat-checkbox: Tap twice CHECKBOX to switch states.
  • mat-radio: Tap twice RADIO to switch states.
  • mat-stepper: Tap three times NEXT button to go across the 3 steps.
  • mat-slider: Tap MINUS button to decrease slider and then tap PLUS 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:
image

A more friendly graph with polynomial smoothing:
image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: manyArea label for issues related to many componentsneeds investigationA member of the team needs to do further investigation to determine the root causeperfThis issue is related to performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions