4

I wanted to use in_memory workspace, however I can't clear it. No matter if I use in Python window, in ArcMap this:

arcpy.Buffer_analysis("something", "in_memory/buffer", 399)
arcpy.Delete_management("in_memory")
arcpy.Buffer_analysis("something", "in_memory/buffer", 3345)

or this:

arcpy.Buffer_analysis("something", "in_memory/buffer", 399)
arcpy.Delete_management("in_memory/buffer")
arcpy.Buffer_analysis("something", "in_memory/buffer", 3345)

I get the following error:

ExecuteError: ERROR 000725: Output Feature Class: Dataset in_memory\buffer already exists. 

In_memory gets normally cleared when I restart ArcMap. How can I clear in_memory?

EDIT:

Output from answer proposed by KHibma:

>>> arcpy.CopyFeatures_management("linie", "in_memory/foo1")
<Result 'in_memory\\foo1'>
>>> arcpy.Exists("in_memory/foo1")
True
>>> arcpy.Delete_management("in_memory")
<Result 'true'>
>>> arcpy.Exists("in_memory/foo1")
True
>>> arcpy.Delete_management("in_memory/foo1")
<Result 'true'>
>>> arcpy.Exists("in_memory/foo1")
True

So it seems that neither of deleting from in_memory methods is working at all.

asked Feb 7, 2017 at 11:12
5
  • 1
    What version of ArcGIS are you running this in? Maybe instead of deleting the object just overwrite it using arcpy.env.overwriteOutput = True Commented Feb 7, 2017 at 14:21
  • I am using 10.3. Overwriting would be only temporary solution. I'd rather have fully functional environment. Commented Feb 7, 2017 at 14:51
  • @Kubson Can you please expand on what you mean by "I'd rather have fully functional environment"? In what way does arcpy.env.overwriteOutput = True not work? Commented Feb 7, 2017 at 15:27
  • @Midavalo For example, if I would like to release memory to perform some further actions (some next loop using previously created objects?) Commented Feb 8, 2017 at 11:44
  • @Kubson Please edit your question in response to any comments rather than adding as additional comment. Commented Feb 8, 2017 at 16:40

1 Answer 1

2

The workflow you describe works as expected for me in the Python window. Perhaps copy/paste all of the python window session into your question, showing the result of each operation.

In short, yes, you can delete items out of the in_memory workspace.

>>> arcpy.CopyFeatures_management(r"Exterior Editing\Trees", "in_memory/foo1")
<Result 'in_memory\\foo1'>
>>> arcpy.Exists("in_memory/foo1")
True
>>> arcpy.Delete_management("in_memory")
<Result 'true'>
>>> arcpy.Exists("in_memory/foo1")
False
>>> arcpy.CopyFeatures_management(r"Exterior Editing\Trees", "in_memory/foo1")
<Result 'in_memory\\foo1'>
>>> arcpy.Exists("in_memory/foo1")
True
>>> arcpy.Delete_management("in_memory/foo1")
<Result 'true'>
>>> arcpy.Exists("in_memory/foo1")
False
answered Feb 7, 2017 at 17:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.