-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/overlayneeds investigationA member of the team needs to do further investigation to determine the root causeA member of the team needs to do further investigation to determine the root cause
Description
I've encountered a possible memory leak while using OverlayRef and Injector.
Reproduction
Inside AppComponent there is a click event on a button. That click event will generate an array and pass that array to another component using ComponentPortal
The constructor and the click event from AppComponent:
// ? AppComponent constructor
constructor(private overlay: Overlay) {
this.#overlayRef = this.overlay.create({
positionStrategy: this.overlay
.position()
.global()
.centerHorizontally()
.centerVertically(),
hasBackdrop: true,
});
this.#overlayRef.backdropClick().subscribe(() => this.#overlayRef.detach());
}
onClick(){
const output = new Array(1000).fill('asfasdf');
this.#overlayRef.attach(
new ComponentPortal(
MyComponent,
null,
Injector.create({
providers: [{ provide: MY_TOKEN, useValue: output }],
})
)
);
}
Actual Behavior
It looks like each time the modal is created the data generated and injected in the component, but once the modal disappears, the data is not removed from the memory.
Environment
-
Angular:
- "@angular/core": "~11.2.5",
-
CDK/Material:
- "@angular/cdk": "^11.2.4",
-
Browser(s): Chrome
-
Operating System (e.g. Windows, macOS, Ubuntu): Windows10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/overlayneeds investigationA member of the team needs to do further investigation to determine the root causeA member of the team needs to do further investigation to determine the root cause