dasmoth / dalliance

Interactive web-based genome browser.
http://www.biodalliance.org/
BSD 2-Clause "Simplified" License
226 stars 68 forks source link

memory leak with adding/removing tracks #149

Closed Traksewt closed 9 years ago

Traksewt commented 9 years ago

There appears to be a memory leak when adding and removing tracks over time.

I reproduced the issue here by removing and readding a track over and over. http://jsfiddle.net/zwy6bwrn/5/

var bounceTiers = function () { browser.removeTier(datasources[0]); browser.addTier(datasources[0]); setTimeout(bounceTiers, 4000); } setTimeout(bounceTiers, 4000);

I then profiled it with google dev tools Profile->heap timelines, and it shows memory allocations building up over time (the blue lines shows what is held - grey is alloc'ed and released memory). image

possibly related to activityListeners not getting released inside OverlayFeatureSource.

Traksewt commented 9 years ago

Not too much memory lost in this example per iteration, but with more tracks, and larger data range, this builds up over time.

dasmoth commented 9 years ago

Thanks, I'll take a look.

Given that I can't see an overlay: option in your config, I don't think OverlayFeatureSource is going to be relevant here. Suspect it may be the caching system in kspace.js.

dasmoth commented 9 years ago

Thanks for reporting this, and for pointing me at the Chrome heap profiler -- great tool!

I've identifier and fixed three major causes of leaking memory. Try http://www.biodalliance.org/dev/dalliance-all.js in your Fiddle to see the improvements. There are a few more loose ends in the event system which I'd like to check through before I cut a new release (should be by the end of the week).

Traksewt commented 9 years ago

great thanks Thomas, looking good!