I've been using "in_memory" quite a bit recently. It can be very useful, as it has the potential to dramatically increase processing speeds for certain tasks, however if you are working with very large datasets, it might cause your program to crash.
You can use "in_memory" to define process outputs... often, if I am performing a task on a feature class, I will copy it to the "in_memory" workspace first:
inFeature = r'C:\myDir.gdb\myFeature'
memoryFeature = "in_memory" + "\\" + "myMemoryFeature"
arcpy.CopyFeatures_management(inFeature, memoryFeature)
Note that you don't have to concatenate memoryFeature together like I did, you could write it out as "in_memory\myMemoryFeature", I just like doing it that way to switch back and forth between "in_memory" and a physical directory easily. You can then perform processes on your feature in memory. When you are done, you can reverse the process to save it back to a directory.
I could be wrong, but I believe it is not the same as creating a feature layer. feature layers give you access to selection methods and other layer specific operations. Think of the "in_memory" directory as the vector equivalent to the raster object (raster = arcpy.Raster(myRasterLocation))
To clean up after using "in_memory" simply add the following line of code:
arcpy.Delete_management("in_memory")
Hope that helps.
The way I think about this distinction is:
A layer (unless written to a layer file or saved as part of a map document) is only stored in memory, but it is not stored in an in_memory workspace.
Remember that when you are in ArcMap, what you see in the Catalog window are spatial datasets (i.e. not much more than x,y coordinates, coordinate system and attributes), and that they only obtain a myriad of other properties to configure such as symbology, MapTips, hyperlinks, etc after you have added them as layers (which appear in the Table of Contents). This is the same distinction as above.
Best Answer
You can add the Delete tool and specify
%in_memory%
as the Input Data Element. I would also makemosaic_clp.img
a precondition for the Delete operation, to make sure thein_memory
workspace isn't cleared prematurely.