Skip to content

listeners invoked inside embedded views cause a memory leak #42848

Closed
@s3141p

Description

@s3141p

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

When a component has a button with click handler and ngIf it won't be destroyed after user click

Please provide a link to a minimal reproduction of the bug

https://github.com/s3141p/Ng-leak

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

Angular CLI: 12.1.1
Node: 14.15.1
Package Manager: npm 6.14.8
OS: linux x64

Angular: 12.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.1
@angular-devkit/build-angular   12.1.1
@angular-devkit/core            12.1.1
@angular-devkit/schematics      12.1.1
@schematics/angular             12.1.1
rxjs                            6.6.7
typescript                      4.2.4

Anything else?

To reproduce:

  1. Clone the repo
  2. ng serve
  3. Click on To B Component link
  4. Click on B button (!! Important step)
  5. Make Memory snapshot
  6. Click on To A Component
  7. Run GC
  8. Make Memory snapshot

Last snapshot will show that BComponent wasn't destroyed.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimecore: event listenersmemory leakIssue related to a memory leakstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions