Skip to content

Commit ee808f8

Browse files
committed
fix(cdk/tree): resolve memory leak (angular#31754)
Fixes a subscription that was never being cleaned up in the tree. Also completes a few subjects. (cherry picked from commit 5406372)
1 parent fab3737 commit ee808f8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cdk/tree/tree.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ export class CdkTree<T, K = T>
282282
ngOnDestroy() {
283283
this._nodeOutlet.viewContainer.clear();
284284

285+
this._nodes.complete();
286+
this._keyManagerNodes.complete();
287+
this._nodeType.complete();
288+
this._flattenedNodes.complete();
285289
this.viewChange.complete();
286290
this._onDestroy.next();
287291
this._onDestroy.complete();
@@ -1403,6 +1407,7 @@ export class CdkTreeNode<T, K = T> implements OnDestroy, OnInit, TreeKeyManagerI
14031407
distinctUntilChanged(),
14041408
takeUntil(this._destroyed),
14051409
)
1410+
.pipe(takeUntil(this._destroyed))
14061411
.subscribe(() => this._changeDetectorRef.markForCheck());
14071412
this._tree._setNodeTypeIfUnset(this._type);
14081413
this._tree._registerNode(this);

0 commit comments

Comments
 (0)