ngRepeat "track by" possible memory leak #16776
Description
I'm submitting a ...
- bug report
- feature request
- other
Current behavior:
Adding a track by
to an ngRepeat
causes a memory leak, so that the component's controller is retained in memory.
Expected / new behavior:
Using track by
on an ngRepeat
should not cause any side effects.
Minimal reproduction of the problem with instructions:
Plunker
To see the memory leak in action, you'll need to run the demo in its own tab: https://run.plnkr.co/plunks/pToAURpUzO2pdOq6H0Yf/
It contains two child components, a "leaky" version and a "non-leaky" version, the only difference between them being the addition of a "track by" on the leaky one.
- Click on "Leaky Component", then "Non-Leaky Component", then "Reset"
- Take a heap snapshot. Filter on "leaky". You'll see that the "leaky" component is still in memory, though not reachable. The "non-leaky" component has been GC'ed and is no longer on the heap.
The presence of "track by" seems to cause a leak. Using track by $index
has the same effect. This seems like a really obvious bug, but I haven't been able to find anything related to it here yet. Am I missing something?
AngularJS version: 1.7.5
Also reproduced in 1.5.8
Browser: Chrome 70