Skip to content

bug(MatMenu): Memory Leak in MatMenu and MatAutocomplete #29696

Closed
@jingglang

Description

@jingglang

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

There are detached elements in memory snapshot after clicking the menu or autocomplete to show the dropdowns. It can be replicated in https://material.angular.io web site.

Reproduction

Steps to reproduce:

  1. Go to https://material.angular.io/components/menu/overview menu component page.
  2. Click a menu to show the drop down. Then click the API tab to destroy the menu component. Repeat this steps several times.
  3. Go to landing page. The menu-related memory should've been destroyed.
  4. Take a memory snapshot.

Do similar steps to reproduce memory leak for Autocomplete.

Expected Behavior

There should be no memory allocation related to MatMenu or MatAutocomplete because the landing page doesn't have them.

Actual Behavior

There are many detached elemets that should've been garbage collected.

Screenshot_20240905_150759

Environment

  • Angular: 18
  • CDK/Material: 18
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Linux 6.8.0-40-generic mdProgressBar #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions