Skip to content

[Tooltip] Memory leak #8989

Open
Open
@anthonn

Description

@anthonn

Bug:

matTooltip directive creates detatched DOM trees when used and then disposed.

If using a tooltip in an component, in my case on a normal div element, there will be a detatched dom tree for each time the view with the components including the tooltip is disposed.

After viewing and exiting a view in my application with tooltips (10 times) the following detached DOM trees could be seen:

image
(It is a comparison from two snapshots in chrome)

I narrowed the problem down and it seems like the (longpress) event in the tooltip host settings is the problem (line 91).

image

If changing this to any other event eg. keyup:

image

Then this memory leak with detatched DOM trees are removed. I have only tested this workaround by changing in the javascript code (both es5 and es6), but I guess it should be the same if changing in the sourcecode also.

My suggestion is to either fix the longpress event or remove it until a correct longpress functionality could be made, because now the tooltip is not really usefull, not on desktop at least.
I unfortunately do not really know how a fix could be done though.

What are the steps to reproduce?

Create a tooltip in a component and then dispose the component. Repeat for more detached DOM trees.

https://stackblitz.com/edit/angular-g2rngj

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

  • Angular - 5.1.1
  • Angular material - 5.0.1
  • Chrome - Version 62.0.3202.94 (Official Build) (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/tooltip

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions