Hello,
how can I delete the memory-workspace after a script has run?
I usually added
arcpy.Delete_management("memory")
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) arcpy.Delete_management(desc.catalogPath)
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?
Cheers
edit: I am using ArcGIS Pro 2.4.3
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).
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
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)
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
@MattWeber2 were you able to figure out the problem with your memory workspace?
Same here I have a pile of scripts that I ran in ArcMap Python for years that use code like below. None of this will work in ArcPro Python. Seems like a bug to me.
I also added arcpy.Delete_management("in_memory") and it still does not work. Kinda stuck now since I cannot get it to ever delete.
Anyone get this one yet? thanks
for table in tableList:
tempTV = "in_memory\\tempTV"
# for FC this line must be different
if table in fcList:
arcpy.MakeFeatureLayer_management(appendFromDB + "\\" + table, tempTV)
else:
arcpy.MakeTableView_management(appendFromDB + "\\" + table, tempTV)
# We want to check for dups based on FormID
arcpy.AddJoin_management(tempTV, "FormID", addToDB + "\\" + sdePrefix + table, "FormID", "KEEP_COMMON")
joinedCount = int(arcpy.GetCount_management(tempTV).getOutput(0))
arcpy.RemoveJoin_management(tempTV)
arcpy.Delete_management(tempTV)
You'll want to switch to using the "memory" workspace in ArcGIS Pro rather than the "in_memory" from ArcMap.
Write geoprocessing output to memory—ArcGIS Pro | Documentation
Yes I know and I tried both for testing. Same issue.