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.

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
    – artwork21
    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.
    – Kubson
    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?
    – Midavalo
    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?)
    – Kubson
    Commented Feb 8, 2017 at 11:44
  • @Kubson Please edit your question in response to any comments rather than adding as additional comment.
    – Midavalo
    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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.