I'm developing an application through the Sample Flex Viewer, and found a weird memory leak. I made a simple test application to test it out, and re-generate the problem. It's like every time I update the dynamicMapServiceLayer, 4MB memory will be added into the browser.I need to update the layer visibility and layer definition on the fly through the code, and every time this function is called, I got the image back and everything looks good except the memory the leak. Check the code below, hope someone can help me figure out. map1.visible=true;
//create the Dynamic Map service object
var myDLayer:ArcGISDynamicMapServiceLayer = map1.layers[0] as ArcGISDynamicMapServiceLayer;
//Change the layers visibility, I have 3 layers in this service
var myVisLayers:ArrayCollection = new ArrayCollection();
myVisLayers.addItem("0");
myVisLayers.addItem("1");
myVisLayers.addItem("2");
//initial layer definition array
var myLayerDefinitions:Array = new Array();
myLayerDefinitions.push("");
myLayerDefinitions.push("");
myLayerDefinitions.push("");
myDLayer.visibleLayers= myVisLayers;
myVisLayers=null;
myDLayer.layerDefinitions = myLayerDefinitions;
myLayerDefinitions=null;
myDLayer.alpha = 1;
myDLayer.visible=true;
myDLayer.Refresh()