AnsweredAssumed Answered

Performance issues and memory leaks opening popups and using FeatureLayers

Question asked by dgallant on Jul 6, 2018
Latest reply on Aug 15, 2018 by kmsagis

I have a map with a MapImageLayer with multiple sublayers and the capability to draw a polygon to select the set of all features contained within the polygon. After selection, I open a popup with the set of all features:

// Merge all the features into a single array of Graphics
const features = featureSets
  .map(featureSet => featureSet.features)
  .reduce((prevValue, curValue) => [...prevValue, ...curValue]);

if (features.length > 0) {
  const location = <__esri.Point>features[0].geometry;

  // Display the popup{

With small selections (10's of features), there are no noticeable issues: the user selects features, and with an acceptably short latency, the popup opens on the first feature in the set. As the selection set becomes larger, however, the latency grows exponentially larger, the CPU usage hits 100%, the app freezes, and memory usage skyrockets. When the map finishes whatever it is doing, the app resumes, but whatever caused the memory spike is creating persistent object references that don't go away even after the map is destroyed, as the garbage collector never frees up that memory. If the selection is large enough (1000's of features), the browser tab will crash before it finishes doing whatever the heck it is trying to do.


Commenting out the call to open the popup eliminates the performance and memory spikes.


I don't know where to begin debugging this. I built a test app that is just a basic map, where a large set of features is loaded into a popup on the click of a button, and I get a different issue where calling never completes, but also somehow does not eat up CPU cycles.


I can get a similar performance issue by loading one of the MapImageLayer sublayers as a FeatureLayer and adding it to the map. If I load the layer as a FeatureLayer, CPU usage spikes to 100% for a few seconds with a small number of features, up to several minutes with 1000's of features. A map with 7000 features took 2 minutes to become usable, and if the user pans or zooms the map, CPU usage spikes again and the map freezes for 10-30 seconds before it becomes usable. I don't strictly need to load the layer as a FeatureLayer, but it would be desirable to be able to do so due to the flexibility of FeatureLayers vs MapImageLayers.


I've tried to replicate these issues with public data sets from the Sample Code pages, and I cannot. It seems like there is something either specific to my ArcGIS server or specific to my data that is causing these problems. Unfortunately, the data is private, so I cannot share it.

Does anyone have any ideas about why these problems might be happening, how I can debug them, or any workarounds that might alleviate them?