jeff.pace

legend bug when combined with map.addLayers

Discussion created by jeff.pace on Aug 6, 2013
I think i found a bug/memory leak.

I have an app that can load layers based on a config.  The layers can be loaded on the fly

setA (15 layers, some dynamic, some tiled)
setB (3 layers, some dynamic, some tiled)
setC (10 layers, some dynamic, some tiled)

I can start the map with setB, and unload reload (remove all, addLayers[setb]) with no problem
I can do the same with A or B, and switch amongst them, without issue.

ERROR
If i add a legend
I can start the map with setB, and unload reload (remove all, addLayers[setb]) with no problem
I can start the map with setA, and switch to setB, without problem. 
If I start with any set, and switch to A or C, firefox usage goes up over 1 gb, goes not responding, never comes back (and the "onaddlayersresult event never fires")

if i change to code to

if(legend){
legend.destroy();
map.addLayers[setB];
createLegend();}

it works perfectly, in just a few seconds.

bug/memory leak? ir bad workflow.  Right now i have to code in to replace the legend , but it seems "hacky"

Outcomes