swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

ngx-datatable not getting garbage collected #1001

Open will093 opened 7 years ago

will093 commented 7 years ago

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

ngx-datatable and its parent component are not ever garbage collected after navigating away to another component, causing a memory leak.

Reproduction of the problem

Add a simple ngx-datatable to some component's template:

<ngx-datatable [rows]="[]" [columns]="[]"></ngx-datatable>

Then navigate away to another route, so that the component is no longer visible.

In the memory tab of the Chrome Dev Tools take a heap snapshot - the component with the ngx-datatable never gets garbage collected.

If I remove ngx-datatable from the component template, then the component does get garbage collected as expected.

wizarrc commented 7 years ago

@will093 can you provide a plunker with the routing you are using?

will093 commented 7 years ago

@wizarrc I tried and failed to reproduce in the following Plunker which replicates the routing for the section of my application with the datatable:

https://plnkr.co/edit/uckO2V?p=info

I think the problem is related to the routing though, because if I load the component containing the datatable at a different place in the route hierarchy, it gets cleaned up as expected.

wizarrc commented 7 years ago

@will093 that's what I was thinking. There were some memory leaks that I fixed in the past, but never the whole thing, which leads me to believe it's a routing or another directive that's holding a reference thus not allowing garbage collection. If you notice part of the table not getting collected, it might be the table that has the leak.

alo commented 5 years ago

I still have the same problem