Components with non-empty HTML input field not released in memory
See original GitHub issueπ bug report
Affected Package
The issue is caused by package @angular/core or forms?Is this a regression?
unsureDescription
If I have an app with 2 pages and routing between them, the components on each page would normally be destroyed when routing between the pages. If a page has an input with [(ngModel)] binding however, the page/component will still call ngOnDestroy but will not be released from memory (see chrome dev tools)π¬ Minimal Reproduction
https://stackblitz.com/edit/angular-b5sb94
Enter something in the input field -> route to page 2 -> route back -> Page1Component will be 2x in the memory
π₯ Exception or Error
n/a
π Your Environment
Angular Version:
10
Anything else relevant? n/a
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
JavaScript validation for empty input field - Stack Overflow
The reason your current code doesn't work is because you don't have a FORM tag in there. Also, lookup using "name" is not...
Read more >JavaScript : HTML form - Checking for non empty - w3resource
Javascript function to check if a field in a html form is empty or not.
Read more >A deep dive into the HTML form input element - LogRocket Blog
This post breaks down the HTML form input element, explains how they works, and shows you how to best apply them in various...
Read more >HTML Form Elements - W3Schools
One of the most used form element is the <input> element. The <input> element can be displayed in several ways, depending on the...
Read more >How to target non-empty but invalid input elements with CSS
How could you show that the field element is invalid after someone interacted with the field? CSS offers the :invalid pseudo-class for that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this should be high prio IMO, since all angular apps will leak large amounts of memory and perform very poorly after some hours of usage. Almost all components have this problem.
I believe I just ran into this same issue. Hereβs the sample repro: https://github.com/nartc/demo-angular-memory-profile
There are two cases (screenshots) that demonstrate this memory issue:
[(ngModel)]
then I changed to[value]
and(input)
just to see if thereβs any difference. No difference at all.ngOnDestroy
in ListItemComponent is being called correctly for each item.Not sure if this is entirely related because the memory issue does not exist if the input isnβt used at all.
PS: I also forgot to mention that the leaked seems to be garbage collected after doing another round of Navigation without changing
currentPage