Skip to content

Commit 22ed4be

Browse files
committed
fix(cdk/tree): retainining previous objects
fixes component retaining old data in memory even when its not used causing memory usage to increase fixes #30322
1 parent 1b3c42e commit 22ed4be

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/cdk/tree/tree.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,12 @@ export class CdkTree<T, K = T>
10611061
renderNodes: readonly T[];
10621062
flattenedNodes: readonly T[];
10631063
}> {
1064+
// clear previously generated data otherwise it is always retained in addition to new data
1065+
// calling clear() manually removes all key pair values allowing retained data to be
1066+
// garbage collected.
1067+
this._parents.clear();
1068+
this._ariaSets.clear();
1069+
this._levels.clear();
10641070
// The only situations where we have to convert children types is when
10651071
// they're mismatched; i.e. if the tree is using a childrenAccessor and the
10661072
// nodes are flat, or if the tree is using a levelAccessor and the nodes are

0 commit comments

Comments
 (0)