[GIS] Clearing in_memory workspace within ModelBuilder

arcgis-desktopin-memorymodelbuilder

I have been using in_memory workspace within ArcGIS 10.1 ModelBuilder as part of a workflow to mosaic and clip raster datasets to study area bounds (Figure 1). The model runs fine the first round but crashes the program on the second or third run. I suspect two issues may be occuring: 1) Memory limitation are being exceeded or 2) There is conflict when trying to overwrite temp files in_memory.

Is there a way to clear in_memory workspace from within ModelBuilder?

Figure 1.

enter image description here

Edit:

The final model that is now stable

enter image description here

Best Answer

You can add the Delete tool and specify %in_memory% as the Input Data Element. I would also make mosaic_clp.img a precondition for the Delete operation, to make sure the in_memory workspace isn't cleared prematurely.