Writing geoprocessing outputs to memory is an alternative to writing output to a geodatabase or file-based format. It is often significantly faster than writing to on-disk formats. Data written into memory is temporary and is deleted when the application is closed, so it is an ideal location to write intermediate data created in a ModelBuilder model or Python script.
ArcGIS provides two memory-based workspaces where geoprocessing outputs can be written.
- Memory-based workspaces do not support geodatabase elements such as feature datasets, subtypes, domains, representations, topologies, geometric networks, or network datasets.
- Folders cannot be created in memory-based workspaces.
- Since memory-based workspaces are stored in your system's physical memory, or RAM, your system may run low on memory if you write large datasets into the workspace. This can negatively impact processing performance.
memory is a new memory-based workspace developed for ArcGIS Pro which currently supports output feature classes and tables.
Raster support in the memory workspace will be added in a future release of ArcGIS Pro.
To write to the memory workspace, specify an output dataset path beginning with memory\ —for example, memory\tempOutput.
You can add memory datasets to a map in ArcGIS Pro.
in_memory is the legacy memory-based workspace built for ArcMap which supports output feature classes, tables, and rasters.
To write to the in_memory workspace, specify an output dataset path beginning with in_memory\ —for example, in_memory\tempOutput.
in_memory datasets cannot be displayed on a map. If you run a geoprocessing tool from the Geoprocessing pane or Python window and write the output dataset to in_memory, after processing, the output dataset will be copied to the project geodatabase and that geodatabase dataset will be added to the map. Writing to the project geodatabase does not occur when in_memory datasets are intermediate and are not added to a map.
Manage the memory workspace
When using a memory-based workspace, any intermediate data should be deleted as soon as possible to free up system memory resources. The Delete tool can be used to delete data in a memory-based workspace. Individual datasets can be deleted, or the entire workspace can be deleted to clear all the workspace contents.
Use the memory workspace in Python
Use of memory-based workspaces in a Python is only valid for geoprocessing tools. Memory is not a general-purpose virtual directory where you can write files or other data.
You can use the memory workspace as shown in the following code sample:
import arcpy # Set the geoprocessing workspace arcpy.env.workspace = r"C:\Data\Habitat.gdb" # Buffer a Roads layer, writing output to memory arcpy.Buffer_analysis("Roads", r"memory\Buffers", 1000) # Erase the buffers from a Vegetation layer arcpy.Erase_analysis("Vegetation", r"memory\Buffers", r"memory\Erased") # Dissolve the memory output of Erase to make a final output in the gdb workspace arcpy.Dissolve_analysis(r"memory\Erased", "FinalOutput")