bug(Tree): Memory leak when changing data source #30322
Labels
area: cdk/tree
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Is this a regression?
The previous version in which this bug was not present was
17.2.2
Description
After upgrading Angular project from v17 to v18, our team noticed a memory leak in the app. After profiling, I found that
mat-tree
component holds references to old node objects after updating the data source, which prevents them from being collected by GC.Reproduction
StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-ujvrwarq?file=src%2Fmain.ts
Steps to reproduce:
Expected Behavior
Old
Node
objects must be collected by GC. The memory heap should contain only those objects that are present in the tree.Actual Behavior
Node
objects are never collected by GC. The size of the memory heap groves over time as node objects accumulate in memory.Environment
The text was updated successfully, but these errors were encountered: