Problem: ArcMap crashes during or after opening a document containing map service layers
When using ArcMap versions 10.5.x or later, ArcMap either crashes while attempting to open, or after opening an existing map document (.mxd) that contains map services.
ArcMap may crash when switching between tabs in the Table Of Contents, adding other layers, editing features, changing a layer's visibility, using the Field Calculator, or running a geoprocessing tool. Additionally, the amount of time that passes before the application crashes depends on the layers or geoprocessing tools used after opening the .mxd.
Because an application may crash for a variety of reasons, this technical article provides suggestions that can help determine if the cause of the crash is related to system limitations.
Most crashes are related to the number of Graphical Device Interface (GDI) objects exceeding application limitations. This is most common in situations where map services are added to the MXD, as these may contain tens or hundreds of legend items with multiple symbol classes.
In Windows XP and later, the system-wide limit is 216, or 65,536 GDI objects. This is managed by the OS by limiting the object count between open applications; ArcMap is limited to 10,000 GDI objects. The number of GDI objects ArcMap is consuming can be viewed any time through the Task Manager:
- Open Task Manager.
- Select the Details tab. Right-click the column header > Select columns.
- Check the box for GDI objects, and click OK.
- Locate the ArcMap application in the task list.
For example, the GDI object count increases when opening an MXD, adding layers to the MXD, switching between tabs in the Table Of Contents, or displaying legend items. If the MXD contains a map service, or if a map service is added to ArcMap, this further increases the GDI object count if the map service contains a large number of layers.
As a precaution, ArcMap does not display more than 100 legend items per map service layer, but this does not account for the situation where hundreds of map service layers each contain less than 100 legend items. Even though ArcMap may not crash at the time of adding the map service layers, navigating around ArcMap or performing analysis on layers in the map may result in exceeding the 10,000 GDI object limit.
- Microsoft Windows Dev Center: GDI Objects
- Microsoft Developer Blog: Debugging a GDI Resource Leak
- Microsoft TechNet: Pushing the Limits of Windows: USER and GDI Objects – Part 1
Solution or Workaround
Use one or more of the following solutions, if applicable, to resolve any application crash issues when working with map services in ArcMap.
- Upgrade ArcMap to 10.7.x to see if it resolves the crash. Esri has made improvements for ArcMap 10.7 that have stopped the high number of reports received for these types of crashes. If ArcMap still crashes, proceed to the next solution.
- Open the document in ArcGIS Pro, as the application does not have the same limitations as ArcMap. In ArcGIS Pro, import your map document by creating a Blank project and select Import Map from the Insert tab.
- Use the Advanced ArcMap Settings utility to set the maximum legend item count to zero. In ArcMap 10.5.x and later, this utility (AdvancedArcMapSettings.exe) is found at:
<drive>\Program Files (x86)\ArcGIS\Desktop10.x\Utilities\AdvancedArcMapSettings.exeFollow the instructions below to modify the number of map service layer legend items that ArcMap is allowed to draw.
- Close all instances of ArcMap running on the machine.
- Open the Advanced ArcMap Settings utility.
- Switch to the TOC/Data tab.
- In the Map server layers group, change the value for maximum number of legend items from each Map Server layer from 100 to 0.
- Restart ArcMap. Open the problematic MXD, or add the map service layers.
- How To: Change the maximum legend items allowed to display for an ArcGIS Server map service layer in ArcMap