How to delete memory-workspace

04-02-2020 11:25 PM
New Contributor II


how can I delete the memory-workspace after a script has run?

I usually added


to the end of my scripts, but noticed yesterday that this apparently doesn't do anything. 

The workaround i found is to loop over all fc in the workspace and delete them one by one.

for fc in arcpy.ListFeatureClasses():
    desc = arcpy.Describe(fc)

But this help site indicates it should be possible to delete all at once.

Write geoprocessing output to memory—ArcGIS Pro | Documentation 

Also, the older in_memory seems to empty itself after a script ran, why doesn't memory do the same?


edit: I am using ArcGIS Pro 2.4.3

14 Replies
MVP Esteemed Contributor

You are seeing different behaviors in IPython/Jupyter and ArcGIS Pro because the memory workspace integrates into ArcGIS Pro (in-process) differently than IPython/Jupyter/python.exe (out-of-process). 

0 Kudos
MVP Esteemed Contributor

Attach your script to a tool in Arctoolbox if you must work inside of Pro.  You can even set your inputs as the default if you have repetitive tasks with the same data.

I still don't know why you would be running a script inside Pro in any event when you can run it outside without locks.  Maybe even try saving the project after the run to see if it frees things up.

I am done, since this may or may not be an error.  Workarounds have been provided.  Tech support is your next option

0 Kudos
MVP Esteemed Contributor

To mess with everyones heads...

Jupyter notebook in pro has some issues with in_memory ( I suspect it only supports 'memory'

Kory Kramer‌  I await beta 2.6 before I invest in Jupyter further, since toolboxes were suggested to be changed (don't know if it happened)

New Contributor II

Since nobody can reproduce the Problem, I assume it's somekind of setting or maybe bug in the Version of Pro my organization is using. 

I will use the workaround to delete all the fc in memory one by one for now. 

Thanks for all the help and testing

0 Kudos
MVP Regular Contributor

@MattWeber2 were you able to figure out the problem with your memory workspace?

0 Kudos