It appears "in_memory" is not really in memory.

958
6
06-12-2012 11:02 AM
DougMcGeehan
New Contributor
I have ArcCatalog 10.0 from the ArcGIS Desktop 10 SP4 suite. Just now, I pulled up the interactive Python window to test some code out in the application's interpreter.

>>> result = arcpy.CreateFeatureclass_management(out_path="in_memory", out_name="in_memory_junk")
>>> type(result)
<class 'arcpy.arcobjects.arcobjects.Result'>
>>> print str(result)
<Result 'C:\\Users\\DMCGEE~1\\AppData\\Local\\Temp\\2\\j6cc4de20957342a3aa8cda7d65b8cc7a.gdb\\in_memory_junk'>


I wasn't expecting to see the result of CreateFeatureclass to reside a temporary file geodatabase in the C:\Users\DMCGEE~1\AppData\Local\Temp\2\ directory. However, it's there, as indicated in the screenshot below.

[ATTACH=CONFIG]15140[/ATTACH]

I realize the documentation for in-memory workspaces indicates that "when data is written to the in-memory workspace, the computer's physical memory (RAM) is consumed", but the fact that the temporary file geodatabase is located in a temporary directory makes me think otherwise.
Tags (2)
0 Kudos
6 Replies
MathewCoyle
Frequent Contributor
in_memory workspace is in memory with a temporary reference to a directory on disk. It should disappear once you close the process it was opened in.
0 Kudos
DougMcGeehan
New Contributor
I haven't been working with ArcGIS for long, so I haven't had the opportunity to test in-memory feature classes to witness any measurable differences. I'll take your word for it, but the idea of a file on disk referencing data in memory doesn't seem very feasible without some sort of low-level process actively translating file-reads to RAM-reads.
0 Kudos
KevinHibma
Esri Regular Contributor
Are you using Background Processing?
Processing in the background means sending the features you want to process over to another process and then getting a result back.
Because its another process we have to persist them to disk for ArcMap to read them on the way back.

Heres the same command with BG on and BG off (foreground processing/processing inside ArcMap):
>>> arcpy.CreateFeatureclass_management("in_memory", "foooo")
<Result 'C:\\Users\\kevi5105\\AppData\\Local\\Temp\\arcC8DF\\jbf5bcaebf45a4c28bfe57a0e27b6e65a.gdb\\foooo'>
>>> arcpy.CreateFeatureclass_management("in_memory", "foooo2")
<Result 'in_memory\\foooo2'>
0 Kudos
DougMcGeehan
New Contributor
Are you using Background Processing?


I'm sure the interactive Python window in ArcCatalog is a background process. This would explain the temporary file geodatabase on disk. Are all 'in_memory' feature classes stored in this way for background processes?
0 Kudos
KevinHibma
Esri Regular Contributor
To say the Python window is a background process isn't really correct.
See this link, hopefully it'll explain background processing. You can enable/disable it and see the different results.
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00210000003q000000
0 Kudos
MarcoBoeringa
MVP Regular Contributor
Are you using Background Processing?
Processing in the background means sending the features you want to process over to another process and then getting a result back.
Because its another process we have to persist them to disk for ArcMap to read them on the way back.


Why o why didn't ESRI document this crucial factor in getting in_memory to work in the Help file???

I really can not find it in the main in_memory Help topic. This issue regarding background processing should be added under the "The following considerations must be made in deciding to write output to the in-memory workspace" text line. I have been struggling with this issue too.
0 Kudos