HtmlInputElement holds all component tree memory leak

🐞 bug report

Affected Package

"@angular/core": "11.1.0"

Is this a regression?

Not sure, possibly.

Description

HtmlInputElement is holding in heap memory the component if I interact with it.
If I do not interact with HtmlInputElement, the component that has the <input type="text" /> inside it, is destoryed.
Tested in Chrome Incognito, without extensions.

🔬 Minimal Reproduction

StackBlitz project: https://stackblitz.com/github/beniaminp/angular-htmlinput-memory-leak
Github project: https://github.com/beniaminp/angular-htmlinput-memory-leak
In the project, I also added 2 MemoryHeapSnapshots at /heap_snapshots and 2 screenshots with the memory difference at /screenshots

Start the project and:

  1. Insert text in input
  2. Press button to switch to next component
  3. Insert text in input
  4. Press button again to switch to previous component
  5. Repeat steps 1-4 as many time as you wish

🔥 Exception or Error

I attached images with heap memory.
First time I start the project:
start_of_the_project

After 6 iterations, FirstComponent
first_component_10_iterations

After 6 iterations, SecondComponent
second_component_10_iterations

🌍 Your Environment

“dependencies”: {
“@angular/animations”: “11.1.0”,
“@angular/common”: “11.1.0”,
“@angular/compiler”: “11.1.0”,
“@angular/core”: “11.1.0”,
“@angular/forms”: “11.1.0”,
“@angular/platform-browser”: “11.1.0”,
“@angular/platform-browser-dynamic”: “11.1.0”,
“@angular/router”: “11.1.0”,
“rxjs”: “~6.5.4”,
“tslib”: “^1.10.0”,
“zone.js”: “~0.10.2”
},
“devDependencies”: {
“@angular-devkit/build-angular”: “0.1101.1”,
“@angular/cli”: “11.1.0”,
“@angular/compiler-cli”: “11.1.0”,
“@angular/language-service”: “11.1.0”,
“@types/node”: “^12.11.1”,
“@types/jasmine”: “~3.5.0”,
“@types/jasminewd2”: “~2.0.3”,
“codelyzer”: “^5.1.2”,
“jasmine-core”: “~3.5.0”,
“jasmine-spec-reporter”: “~4.2.1”,
“karma”: “~4.4.1”,
“karma-chrome-launcher”: “~3.1.0”,
“karma-coverage-istanbul-reporter”: “~2.1.0”,
“karma-jasmine”: “~3.0.1”,
“karma-jasmine-html-reporter”: “^1.4.2”,
“protractor”: “~5.4.3”,
“ts-node”: “~8.3.0”,
“tslint”: “~6.1.0”,
“typescript”: “4.1.3”
}

2 thoughts on “HtmlInputElement holds all component tree memory leak