arcpy.AddMessage(arcpy.Exists(r"memory\copied"))
arcpy.CopyFeatures_management("to_copy", "memory\copied")
arcpy.AddMessage(arcpy.Exists(r"memory\copied"))
arcpy.Delete_management("memory")
arcpy.AddMessage(arcpy.Exists(r"memory\copied"))
Output is
False, True, True the first time the script runs, True True True the second time and onwards
So line 4 doesn't do anything, and even after the Tool finished, fc in memory persist.
Replacing line 4 with the specific delete-call:
arcpy.Delete_management(r"memory\copied")
gives the expected result of False, True, False for any number of runs
If I use the older "in_memory" it works fine by the way.
arcpy.AddMessage(arcpy.Exists(r"in_memory\copied"))
arcpy.CopyFeatures_management("to_copy", "in_memory\copied")
arcpy.AddMessage(arcpy.Exists(r"in_memory\copied"))
arcpy.Delete_management("in_memory")
arcpy.AddMessage(arcpy.Exists(r"in_memory\copied"))
Output is:
False, True, False
And even if I remove line 4 and 5 the output is
False, True
for any number of runs. So the temporary fc saved in_memory are not kept in between runs.