Skip to content

Commit

Permalink
fix(core): fix memory leak on application reference destroy
Browse files Browse the repository at this point in the history
When an application reference is destroyed it stays in memory because it is still registered in the testability registry.

Closes angular#22106, angular#13725
  • Loading branch information
tmair authored and Ratko Rudic committed Apr 4, 2018
1 parent 5298b2b commit 63a004c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/application_ref.ts
Expand Up @@ -564,6 +564,10 @@ export class ApplicationRef {
private _unloadComponent(componentRef: ComponentRef<any>): void {
this.detachView(componentRef.hostView);
remove(this.components, componentRef);
const testabilityRegistry = componentRef.injector.get(TestabilityRegistry, null);
if (testabilityRegistry) {
testabilityRegistry.unregisterApplication(componentRef.location.nativeElement);
}
}

/** @internal */
Expand Down

0 comments on commit 63a004c

Please sign in to comment.