You can control whether tools execute in the foreground or background by clicking Geoprocessing > Geoprocessing Options on the Standard toolbar.
The Background processing panel is where you control whether a tool executes in foreground or background mode.
- If Enable is checked, tools execute in the background, and you can continue working with ArcMap (or other ArcGIS applications, such as ArcGlobe) while the tool executes. You'll see a progress bar at the bottom of your document displaying the name of the currently executing tool. When the tool finishes executing, a pop-up notification appears on the system tray. You can control how long the notification message appears by moving the Notification slider or disable the message by moving to the far left.
- If Enable is not checked, tools execute in the foreground. When a tool is executing in foreground mode, you must wait until the tools stop executing before you can continue with other work.
Background processing
When you execute a tool using its dialog box or from the Python window, you'll see the tool's progress as illustrated below.
You can also track progress in the Results window. The Results window can be opened in the following ways:
- Open the Results window by clicking Geoprocessing > Results.
- Click the status bar (illustrated above) in the bottom of your ArcMap window to open the Results window to the tool currently executing.
- Click the success or fail pop-up message to open the Results window directly to that tool's execution messages.
While a tool is running in the background, you can submit more tools to be run by using the tool dialog box. Only one tool will run in the background; all other tools will be pending (waiting to run). Once a tool finishes executing, the next pending tool will start executing.
You will not be able to start an edit session if there are tools running in the background. If there are tools running in the background, a message box appears notifying that the edit session cannot be started. You must allow all geoprocessing tools running in the background to complete (or cancel them) before beginning an edit session.
With background processing, when you execute a tool in the Python window, the Python window cannot be used until the tool has finished executing.
Custom model and script tools run in foreground by default
Your custom model and script tools will run in the foreground by default, even if you've enabled background processing. To allow your custom tools to run in the background, you must do two things:
- Ensure that your tool follows the guidelines specified in Running custom (model or script) tools in the background.
- Right-click your custom model or script tool and click Properties. On the General tab, uncheck Always run in foreground.
Affected ArcMap layers are locked when a tool is running in background
When the output of a geoprocessing tool is a layer in the map (such as with the Select Layer By Attribute tool) or the tool modifies the input data (such as the Add Field tool or any of the tools in the Editing toolbox), the layer will be locked while the tool is running. A lock icon will appear over the layer in the table of contents to signify the layer is locked for processing. Any refreshing of the map display while a layer is locked will result in the layer not being drawn. Once the tool has finished processing, the map display will refresh and you can resume work on the layer.
Canceling a tool executing in the background
To cancel the execution of a tool running in the background, open the Results window and find the tool that is currently executing (it will have an hourglass or processing clock icon next to it). Right-click the result and click Cancel. This method can also be used to cancel queued tasks that have not yet run.
When a tool receives the cancel instruction, it attempts to clean up after itself, deleting any data it created and issuing a warning message. Depending on the type of clean-up work the tool was doing, cancelling may take a few moments.
System tools may execute in foreground even when background is enabled
There are times when tools execute in the foreground even if background processing is enabled:
- If you are editing data, all geoprocessing tools execute in the foreground. Even if the data you are editing is not used by geoprocessing tools, ArcGIS will still execute all tools in the foreground. This is to prevent a situation where a tool running in the background modifies data that you are editing.
- If you open the ModelBuilder window and run a model, all processes in the model execute in the foreground. Working in the ModelBuilder window is similar to an edit session. Any processes run do so in the foreground to prevent a situation where changing the workflow could cause undesirable results.
- Some system tools, such as the Upgrade Geodatabase tool, always run in the foreground due to data locking and integrity needs. Other system tools may run in the foreground if they need to access the current map document.
Using the in-memory workspace with background processing
The in-memory workspace has many of the same properties of the file geodatabase, with the distinct difference of holding features and rasters in-memory. While the application is active, the data is stored in the system's internal memory (RAM). There are typically performance gains from working with the in-memory workspace as the system does not need to write to the disk. Keep in mind the following points while using the in-memory workspace with background processing:
- Background processing is a separate process from ArcMap or ArcCatalog. These processes cannot share memory (RAM). When a tool is executed, the data it uses must be opened by the background processes. So, an input feature class will be opened directly by the background processes, but layers in ArcMap must follow a different path. For example, suppose you have an input point feature layer in ArcMap and you want to buffer these points with the output written to ArcMap's in-memory workspace. Upon executing the Buffer tool in background, the input features are written to disk, the background process reads them from disk into memory, Buffer is executed, Buffer then writes the output to it's own background in-memory workspace, the output then gets written to disk so that ArcMap can the read buffer output back into its own respective in-memory workspace. The result of all this is that there's rarely any performance benefit when using a single tool that writes output to the in-memory workspace. However, a model or script that runs multiple tools and writes its intermediate data to the in-memory workspace is much more likely to process faster because there is no need to transfer data between two different in-memory workspaces. So, rather than execute one tool at a time from ArcMap while using background processing, create a model or script for your workflow.
- Most of the Create tools, such as Create File GDB and Create Feature Class take two input parameters (a workspace and a name) to derive a new output. These tools allow you to input in_memory as the workspace. However, when executed in the background, the newly created output will always have the result returned as a location on disk, even if in_memory is used as the workspace. These tools are better used as part of a workflow in ModelBuilder or a Python script tool where the in-memory workspace can be used throughout the entire execution of the tool.
Exiting applications when tools are waiting or running in the background
From ArcMap (or ArcGlobe or ArcScene), you can exit and save the document while tools are running or pending. If you exit, all running tools will be stopped. The status of the running and pending tools will be changed to Not Run inside the saved document's Results window. These entries will have hollow icons and can be run by right-clicking the result and clicking Re Run.
A tool that is running or pending when ArcCatalog is exited will be immediately stopped. The result of the tool is moved to the Not Run section of the Results window. The tool can be rerun in the same way as previously mentioned.
Foreground processing
When background processing is disabled, tools execute in the foreground, and you must wait for the process to finish before you can use the application again. Once tool execution begins, the progress dialog box appears, as illustrated below. Click Details to view the execution messages.
A warning message will appear as green text in the tool's messages, prefixed with WARNING followed by a numeric code. A warning means that the output may not contain what you expect. In the case illustrated below, the tool created empty output. The numeric code is a hyperlink—you can click it to view a full description of the warning and possible solutions.
An error message appears in red text, prefixed with ERROR followed by a numeric code.
Once a tool executes and you close the progress dialog box, you can review all aspects of a tool's execution in the Results window.
Canceling a tool executing in the foreground
During tool execution, you can cancel execution by clicking the Cancel button on the progress dialog box.
When a tool receives the cancel instruction, it attempts to clean up after itself, deleting any data it created and issuing a warning message. Depending on the type of clean-up work the tool was doing, cancelling may take a few moments.
Performance considerations
Background processing can be thought of as another ArcMap session running on your computer but without the ArcMap window open. This additional process (session) is launched the first time a tool executes in the background and remains until you exit your ArcMap session. You will notice a brief delay on the first tool execution as the background process is started.
When working with large datasets, some geoprocessing tools, particularly those that use tiled processing, need as much of your computer resources (memory and CPU) as you can make available. If a tool you submitted for background processing fails because there is not enough memory available (error "000426: Out Of Memory" or error "999998: Unexpected Error"), you can try the following:
- Identify and exit nonessential memory-intensive applications.
- Disable background processing from the Geoprocessing Options dialog box (Geoprocessing > Geoprocessing Options). This shuts down the background process and frees up resources.
- Rerun the tool.
By following the above procedure, background processing is bypassed; the additional background process does not start, and the resources it would consume are now available for your tool to make use of. While the tool is executing, avoid starting any memory-intensive applications.