mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.81k stars 1.98k forks source link

setColumns to show/hide column header seems to be leaking memory #386

Open cheman opened 12 years ago

cheman commented 12 years ago

Testing in chrome with example4-model.html and monitoring the task manager. After triggering a sequence of show/hide column event, mem usage was increasing very quickly. Also sees using chrome developer tools, the detached dom tree counts increases whenever setColumns is called.

mleibman commented 12 years ago

First of all, it does seem to leak, but not nearly as much as you're suggesting. Keep in mind that Chrome has a lazy generational GC that can take as much as 5 cycles to fully collect. In the same example, running "grid.setColumns(grid.getColumns())" on a 50ms interval, the memory use starts climbing fast, but then the GC becomes more aggressive and the memory usage growth slows down to about 1Mb every 15 seconds (i.e. every 300 calls to grid.setColumns()).

I've tried to figure out what the leakages were, but I still don't know how to use the heap profiler effectively, and I couldn't find any tutorials that are in-depth enough. Perhaps somebody can help with that.

mobichel commented 9 years ago

Hi,

We're using SlickGrid in our application and noticed unexpected memory growth when call setColumns() many times.

I modified example1-simple.html to call setColumns() continuously with 1 sec interval and see that memory usage continuously increases and cannot be released even after GC forcing. Also noticed continuously climbing number of dettached DOM elements.

UPDATE: I also tried same case with jQuery v1.11.0 and didn't notice dettached DOM elements growth or growth of heap but private bytes of Chrome process are still climbing.

6pac commented 9 years ago

I haven't done memory monitoring in Chrome before, but I set up the program you suggest (every one second up to 100 repetitions) and gave it a go and the grid seems to be fine. Memory is allocated but then gets released later on. If the problem is with the memory use of Chrome itself within Windows rather than the javascript VM's indicated use, then I think this is not a javascript or SlickGrid issue, rather one with Chrome itself.