kendo-angular icon indicating copy to clipboard operation
kendo-angular copied to clipboard

Memory leak in TreeList

Open mbechev opened this issue 3 years ago • 1 comments

Describe the bug When the TreeList component is rerendered multiple times, a memory leak is observed. Here is a stats comparison between the Grid and TreeList:

Grid:

image

TreeList:

image

To Reproduce treelist-A14.zip

  1. Download and unzip the folder.
  2. Run npm install.
  3. Execute ng serve.

mbechev avatar Aug 19 '22 14:08 mbechev

Consider fixing this issue in the previous major v2.x.x of the component.

mbechev avatar Aug 30 '22 13:08 mbechev

A client observed that the memory leak is probably caused by the subscription in the BrowserSupportService class.

The implements ngOnDestroy where the subscription is unsubscribed:

@Injectable()
export class BrowserSupportService implements OnDestroy {
    constructor(private zone: NgZone, private changeDetector: ChangeDetectorRef) {
        ...
        this.zone.runOutsideAngular(() => {
            this.subscriptions = fromEvent(window, 'resize').pipe(
                auditTime(100)
            ).subscribe(() => {
                if (cachedPixelRatio !== window.devicePixelRatio) {
                    ...
                }
            });
        });
    }

    public ngOnDestroy(): void {
        if (this.subscriptions) {
            this.subscriptions.unsubscribe();
            this.subscriptions = null;
        }
    }

But the TreeList doesn't implement OnDestroy hook at all, hence the subscription is not unsubscribed.

Private support thread: 1613018

mbechev avatar Jun 19 '23 11:06 mbechev

Fixed in v13.1.0.

mbechev avatar Jul 06 '23 07:07 mbechev