You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior
I'm using ngTemplateOutlet in a similar way to render a table:
<template#cell1let-dataItem>
{{dataItem.field1}}
</template><table><tr*ngFor="let dataItem of data"><td><template[ngTemplateOutlet]="cell1" [ngOutletContext]="{ $implicit: dataItem }"></template></td></tr></table>
The heap size and node count grows uncontrollably when updating the data.
Expected behavior
The heap size and node count should remain fairly constant since we're only replacing their content.
Note that the application is running in production mode.
Minimal reproduction of the problem with instructions
I'm wondering what the minimum version of Angular 2.x is needed to resolve this bug. Our application is using Angular 2.4.10 and I am hoping to fix this memory leak without needing to upgrade the app to Angular 4.
@sgrinich upgrading from 2 to 4 shouldn't be too hard. Also 4.x is an LTS release.
Check out the Angular Update Guide for a summary of the necessary changes.
Activity
DaveMBush commentedon Mar 29, 2017
For the record, this happen in Windows (7) environment as well
alexzuza commentedon Mar 29, 2017
Will this solve the problem?
Without

ngOnDestroyAfter applying the code above

https://plnkr.co/edit/ciBnuI1m6xYO9cyjj5zH?p=preview
ericmartinezr commentedon Mar 29, 2017
related to #14919 ?
tsvetomir commentedon Mar 29, 2017
@alexzuza it helps indeed :) Your version of ngTemplateOutlet does not leak memory:
@ericmartinezr maybe the references are kept by the template outlet and selecting them with @ContentChildren is not necessary for the leak to occur.
tbosch commentedon Mar 29, 2017
Hi,
could you make a version that also destroys the component that contains the declaration place of the
<template>?tsvetomir commentedon Mar 30, 2017
@tbosch I'm not sure what I should do. Should I move the templates to a sub-component?
tbosch commentedon Apr 10, 2017
Yes, fixing
ngTemplateOutletis the right place.1 remaining item
tbosch commentedon May 5, 2017
Thinking about this a bit more, I think we can fix this in a general way, without needing to change
ngTemplateOutlet... Working on it...fix(core): detach projected views when a parent view is destroyed
fix(core): detach projected views when a parent view is destroyed
fix(core): detach projected views when a parent view is destroyed (an…
fix(core): detach projected views when a parent view is destroyed (an…
sgrinich commentedon Jun 16, 2017
Hi,
I'm wondering what the minimum version of Angular 2.x is needed to resolve this bug. Our application is using Angular 2.4.10 and I am hoping to fix this memory leak without needing to upgrade the app to Angular 4.
tsvetomir commentedon Jun 18, 2017
@sgrinich upgrading from 2 to 4 shouldn't be too hard. Also 4.x is an LTS release.
Check out the Angular Update Guide for a summary of the necessary changes.
sgrinich commentedon Jun 19, 2017
Ok, thanks @tsvetomir
fix(core): detach projected views when a parent view is destroyed (an…
fix(core): detach projected views when a parent view is destroyed (an…
angular-automatic-lock-bot commentedon Sep 11, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(core): detach projected views when a parent view is destroyed (an…