<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can Adding/Removing Dynamic Map Layers on the fly cause memory problems on server in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8886#M197</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Got a few questions for you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. How do you know that it's a memory issue? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Is your RAM usage getting higher every time you add/remove a map layer? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Is ArcGIS Server and the Flex application on the same machine? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. If so, can you reproduce the problem if the Flex application is on a different machine?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. Have you also tried testing ArcGIS Server and the Flex application on a different machine?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can't reproduce the problem using different machines then more than likely the problem isn't with the API so then I would check your web server logs.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2012 21:40:55 GMT</pubDate>
    <dc:creator>ThaoLe</dc:creator>
    <dc:date>2012-05-11T21:40:55Z</dc:date>
    <item>
      <title>Can Adding/Removing Dynamic Map Layers on the fly cause memory problems on server?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8885#M196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have an application that adds/removes dynamic map layers based on the user selection from a combobox.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using Flex API 1.9. The map services are running on ArcServer 9.3 on a Windows 2003 server. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;One of the map services has 37 layers (including a couple of group layers). Should I break it up?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm also using labeling on a lot of the layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Lately we've been having issues with our server having memory problems. I suspect it is either one of my map services, or the way&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;my application adds/removes dynamic layers that is causing the trouble. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code for adding/removing layers. I am adding them over my base map and aerial caches.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This code is called when the user selects a new "view" from the drop-down.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there potential memory problems here? Something with the soc/som?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The list in the switch block is actually much longer. I just put in a few to save space&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private function addLayers():void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGraphicsLayer.clear();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Some layers will not have anything visible at full extent
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add busy cursor so user knows something is happening
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Then remove it when layer has been loaded&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CursorManager.setBusyCursor();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Remove layers that have already been loaded
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var n:Number = MainMap.layers.length -1; n &amp;gt;= 0; n--) //loop thru all map layers
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; var layer:Layer = MainMap.getLayer(MainMap.layerIds&lt;N&gt;);
&amp;nbsp;&amp;nbsp; if (layer.id == "viewLayer" || layer.id == "viewLayer2")
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; MainMap.removeLayer(layer);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }

&amp;nbsp;&amp;nbsp; // Create 2 new Dynamic Map layers 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var lyr:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var lyr2:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create an array collection so only certain layers can be displayed
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // If nothing is added to this ArrayCollection all visible layers in mxd are displayed
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var visibleLayers:ArrayCollection = new ArrayCollection;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var visibleLayers2:ArrayCollection = new ArrayCollection;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set up map layer based on the currently selected view
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (cbViews.text)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "Annexations (City Limits)":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.url = SERVER_NAME + "intranet/CityViewWeb/MapServer";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visibleLayers.addItem([12]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.alpha = 0.5;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "Building Inspection Areas":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.url = SERVER_NAME + "intranet/CityViewWeb/MapServer";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visibleLayers.addItem([2, 3]); // Only draw the inspection areas layer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.alpha = 0.5;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "Business Licenses":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.url = SERVER_NAME + "public/buslicense/MapServer";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "Cell Sites":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.url = SERVER_NAME + "intranet/CityViewWeb/MapServer";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.alpha = 0.7;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visibleLayers.addItem([36, 37]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
 default: // For any view not in list above
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CursorManager.removeBusyCursor();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.id = "viewLayer";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.addEventListener(LayerEvent.LOAD, lyrLoad);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Only draw layers added to ArrayCollection, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if nothing has been added all visible layers in mxd are shown
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (visibleLayers.length &amp;gt; 0){lyr.visibleLayers = visibleLayers};

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add layer to stack, just before parcel layer (so parcels appear on top)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainMap.addLayer(lyr, 1);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add 2nd layer if it is needed&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (lyr2.url != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr2.id = "viewLayer2";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (visibleLayers2.length &amp;gt; 0){lyr2.visibleLayers = visibleLayers2;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainMap.addLayer(lyr2, 2);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Move map tips layer back to top so map tips work
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MainMap.reorderLayer("MapTipsGraphicsLayer", MainMap.layers.length);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
 // Removes busy cursor after layer has been loaded
&amp;nbsp;&amp;nbsp;&amp;nbsp; private function lyrLoad(event:Event):void
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CursorManager.removeBusyCursor();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/N&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2012 21:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8885#M196</guid>
      <dc:creator>BrendanLee</dc:creator>
      <dc:date>2012-05-01T21:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Can Adding/Removing Dynamic Map Layers on the fly cause memory problems on server</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8886#M197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Got a few questions for you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. How do you know that it's a memory issue? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Is your RAM usage getting higher every time you add/remove a map layer? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Is ArcGIS Server and the Flex application on the same machine? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. If so, can you reproduce the problem if the Flex application is on a different machine?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. Have you also tried testing ArcGIS Server and the Flex application on a different machine?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can't reproduce the problem using different machines then more than likely the problem isn't with the API so then I would check your web server logs.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 21:40:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8886#M197</guid>
      <dc:creator>ThaoLe</dc:creator>
      <dc:date>2012-05-11T21:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Can Adding/Removing Dynamic Map Layers on the fly cause memory problems on server</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8887#M198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Got a few questions for you&lt;BR /&gt;&lt;BR /&gt;1. How do you know that it's a memory issue? &lt;BR /&gt;2. Is your RAM usage getting higher every time you add/remove a map layer? &lt;BR /&gt;3. Is ArcGIS Server and the Flex application on the same machine? &lt;BR /&gt;4. If so, can you reproduce the problem if the Flex application is on a different machine?&lt;BR /&gt;5. Have you also tried testing ArcGIS Server and the Flex application on a different machine?&lt;BR /&gt;&lt;BR /&gt;If you can't reproduce the problem using different machines then more than likely the problem isn't with the API so then I would check your web server logs.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The server stops responding and we are unable to log in or reboot it. We're still troubleshooting but it seems to be a memory issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've since removed all maplex labeling and have broke the largest map services into smaller ones. The maps draw much faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are still having issues occassionally. It's now looking like it might be something to do with queries overloading the server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a pop-up that displays info from several layers when the user does an identify. It can be up to 10 successive queries.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a limit on the number of queries before you run into problems? I think I read somewhere it's 25 consecutive per second.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Everything is on the same server (data, ArcGIS Server and the flex app). We moved everything to a different sever and it happens occassionally.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 20:22:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/can-adding-removing-dynamic-map-layers-on-the-fly/m-p/8887#M198</guid>
      <dc:creator>BrendanLee</dc:creator>
      <dc:date>2012-05-29T20:22:02Z</dc:date>
    </item>
  </channel>
</rss>

