Skip to content

Memory leak in mat-drawer and mat-sidenav #11335

Closed
@tran4o

Description

@tran4o

Bug, feature request, or proposal:

Memory leak in mat-drawer, mat-sidenav after destroy

What is the expected behavior?

Full cleanup

What is the current behavior?

Transition engine not freed-up

What are the steps to reproduce?

Simple show / hide with recreation (*ngIf)

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 6.0.0 Material 6.0.2

Is there anything else we should know?

Dirty workaround would be a nav-patch directive :

<mat-drawer nav-patch ..

@directive({
selector: '[nav-patch]',
outputs : []
})
export class NavPatch {
constructor(private eref: ElementRef,private renderer : Renderer) {
var t : any = renderer;
while (t.delegate && (!t.engine || !t.engine._transitionEngine)) t=t.delegate;
this._transitionEngine = t.engine._transitionEngine;
}
ngOnDestroy() {
// PATCH : CLEAR REFERENCES
this._transitionEngine.statesByElement.delete(this.eref.nativeElement);
this._transitionEngine.playersByElement.delete(this.eref.nativeElement);
}
private _transitionEngine;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions