question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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?

unsure

Description

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

image

πŸ”₯ Exception or Error

n/a

🌍 Your Environment

Angular Version:


10

Anything else relevant? n/a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
capc0commented, Jul 17, 2020

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.

3reactions
nartccommented, Sep 19, 2020

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:

image image

  • The currentPage input was initially a [(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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found