Skip to content

Memory leak when using ngTemplateOutlet #15578

Closed
@tsvetomir

Description

@tsvetomir

I'm submitting a ...

[x] bug report

Current behavior
I'm using ngTemplateOutlet in a similar way to render a table:

<template #cell1 let-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.

image

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

  1. Open this plunkr for 2.0.10 or this plunkr for 4.0.0.
  2. Start your browsers memory profiler or observe the process memory usage
  3. Notice that memory is not reclaimed

What is the motivation / use case for changing the behavior?
Application memory usage should be stable.

Please tell us about your environment:
Linux

  • Angular version: 2.4.10, 4.0.0

  • Browser: Chrome 57 | Firefox 52

  • Language: TypeScript 2.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions