From 8e91cdd10c72fd6d4bbbcc4076c0481ba78ec970 Mon Sep 17 00:00:00 2001 From: Thomas Mair Date: Thu, 15 Feb 2018 10:18:29 +0100 Subject: [PATCH] fix(core): fix memory leak on application reference destroy When an application reference is destroyed it stays in memory because it is still registered in the testability registry. Closes #22106, #13725 --- packages/core/src/application_ref.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/application_ref.ts b/packages/core/src/application_ref.ts index 87e8bfb1ff692..788ad8158a5f0 100644 --- a/packages/core/src/application_ref.ts +++ b/packages/core/src/application_ref.ts @@ -564,6 +564,10 @@ export class ApplicationRef { private _unloadComponent(componentRef: ComponentRef): void { this.detachView(componentRef.hostView); remove(this.components, componentRef); + const testabilityRegistry = componentRef.injector.get(TestabilityRegistry, null); + if (testabilityRegistry) { + testabilityRegistry.unregisterApplication(componentRef.location.nativeElement); + } } /** @internal */