<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is in_memory Worth Using? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370982#M29327</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Holy Cow!&amp;nbsp; I copied the two layers I'm working with to new features "in_memory", then changed all layer references from the real layers to the memory layers, and instead of 10 hours, it's looking more like 45 minutes, assuming the RAM isn't exceeded.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Oct 2013 16:16:18 GMT</pubDate>
    <dc:creator>GeoffOlson</dc:creator>
    <dc:date>2013-10-24T16:16:18Z</dc:date>
    <item>
      <title>Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370976#M29321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a script that uses selection sets and cursors and it populates the field accordingly, but because there are so many records (about 130,000) I was wondering if it could be sped up by using in_memory, which I just learned about.&amp;nbsp; I understand that in_memory is good until it's all used up and then it's super slow.&amp;nbsp; I also understand that writing data to RAM is also only temporary and has to be retrieved from RAM back to the HDD.&amp;nbsp; Are there certain instances where it's useful like a new feature layer or table is being created in RAM instead of something like an update cursor?&amp;nbsp; I'll post my code below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os, time
from datetime import datetime
from datetime import timedelta

#set map doc and the layer to be used
mxd = arcpy.mapping.MapDocument("Current")
mapLyr1 = arcpy.mapping.ListLayers(mxd, "NEW_BiState_Grid400_IowaSP") [0]
mapLyr2 = arcpy.mapping.ListLayers(mxd, "NEW_BiState_Grid100_IowaSP") [0]

#alpha will be assigned a letter to rows2 update, there are 16
place = 0
alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P']
searchrow = 0
ck1 = searchrow
ck2 = ck1 + 1
ck3 = ck2 + 1
ck4 = ck3 + 1
ck5 = ck4 + 1
cl1 = timedelta()
cl2 = timedelta()
cl3 = timedelta()
cl4 = timedelta()
cl5 = timedelta()
rows1 = arcpy.SearchCursor(mapLyr1, "", "", "Name")
rowcount = int(arcpy.GetCount_management(mapLyr1).getOutput(0))
allrows = (rowcount + 0.0)
for row in rows1:
&amp;nbsp;&amp;nbsp;&amp;nbsp; clock1 = datetime.now()
&amp;nbsp;&amp;nbsp;&amp;nbsp; bigtile = str()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(mapLyr1, "NEW_SELECTION", '"FID" = %s' %searchrow)
&amp;nbsp;&amp;nbsp;&amp;nbsp; bigtile = row.getValue("Name")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print bigtile
&amp;nbsp;&amp;nbsp;&amp;nbsp; searchrow = searchrow + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; prgrow = (searchrow + 0.0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(mapLyr2, "HAVE_THEIR_CENTER_IN", mapLyr1, 0, "ADD_TO_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows2 = arcpy.UpdateCursor(mapLyr2, "", "", "", "FID")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row2 in rows2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row2.tile = bigtile + alpha[place]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows2.updateRow(row2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; place = place + 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if place == 16:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; place = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(mapLyr1, "CLEAR_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(mapLyr2, "CLEAR_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; prgrss = ((prgrow / allrows)*100.0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; rowsleft = rowcount - searchrow
&amp;nbsp;&amp;nbsp;&amp;nbsp; clock2 = datetime.now()
&amp;nbsp;&amp;nbsp;&amp;nbsp; clock3 = (clock2 - clock1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if ck1 == searchrow:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cl1 = clock3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ck1 = ck1 + 5
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif searchrow == ck2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cl2 = clock3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ck2 = ck3 + 5
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif searchrow == ck3:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cl3 = clock3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ck3 = ck3 + 5
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif searchrow == ck4:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cl4 = clock3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ck4 = ck4 + 5
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif searchrow == ck5:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cl5 = clock3
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ck5 = ck5 + 5
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if searchrow &amp;lt; 5:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif searchrow &amp;gt; 4:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clock4 = ((cl1 + cl2 + cl3 + cl4 + cl5)/5)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clock5 = (clock4 * rowsleft)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clock6 = str(clock5)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("The last 5 iterations averaged %s" %clock4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("%s estimated time remaining" %clock6)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("%d%% completed - row %d out of %d rows" %(prgrss, searchrow, rowcount))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("______________________________")
del mxd, row, rows1, row2, rows2, searchrow, place, bigtile, rowcount, prgrow, allrows, prgrss, rowsleft, clock1, clock2, clock3&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Oct 2013 16:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370976#M29321</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-10-23T16:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370977#M29322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have gotten some massive performance gains using in_memory over HDD workspaces, especially if you don't use RAID/SSD drives. I did some benchmarking a while back but can't find the results. Depending on the task it could be twice as fast to 20 times faster. Cursors on in_memory tables were the most gains IIRC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And yes, the caveat, you also have to keep on eye on the size of data you are writing to memory. I've crashed machines not being diligent about what is in memory and clearing unneeded data. 64-bit geoprocessing won't help you when trying to commit 64GB of data to memory.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Oct 2013 17:55:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370977#M29322</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-10-23T17:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370978#M29323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have gotten some massive performance gains using in_memory over HDD workspaces, especially if you don't use RAID/SSD drives. I did some benchmarking a while back but can't find the results. Depending on the task it could be twice as fast to 20 times faster. Cursors on in_memory tables were the most gains IIRC.&lt;BR /&gt;&lt;BR /&gt;And yes, the caveat, you also have to keep on eye on the size of data you are writing to memory. I've crashed machines not being diligent about what is in memory and clearing unneeded data. 64-bit geoprocessing won't help you when trying to commit 64GB of data to memory.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x2!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a def I use in most of my Python tools/implementations that I am using in_memory.&amp;nbsp; I will insert a call to this before executing the rest of the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

def clearINMEM():
&amp;nbsp;&amp;nbsp; """ clear out the IN_MEMORY workspace of any featureclasses, rasters and tables """
&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = "IN_MEMORY"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcs = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tabs = arcpy.ListTables()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasters = arcpy.ListRasters()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### for each FeatClass in the list of fcs's, delete it.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in fcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(f)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted: " + f)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### for each TableClass in the list of tab's, delete it.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for t in tabs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(t)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted: " + t)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ### for each Raster in the workspace, delete it
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for r in rasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(r)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("deleted " + str(r))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("The following error(s) occured attempting to clear WS " + arcpy.GetMessages(2))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:11:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370978#M29323</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T17:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370979#M29324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Typically a computer will read data from disk into RAM, select from RAM and pass to CPU for calculation, the result is passed back to RAM, then it is written to disk. The computer pretty much does this when you do any calculation (note that database management systems, including ArcGIS, are heavily optimized to try and do this as fast as possible, and will not load the whole dataset into memory at one time unnecessarily). The advantage of in_memory is that operations in RAM are very fast, compared to reading/writing from a hard disk, and that you can skip some disk writes/reads if you are doing sequential calculations on a set of data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The more calculation steps you have between reading and writing, the greater the potential benefit of using in_memory. &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;However&lt;/STRONG&gt;&lt;SPAN&gt;, if you are only doing one calculation, using in_memory may be no faster (and possibly slower, given the additional steps) than calculating directly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I understand that in_memory is good until it's all used up and then it's super slow.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Correct. If your computer has 2GB of RAM installed (physical memory), about 1.5 might be available for processes to use. Sometimes this amount won't be enough, so modern operating systems take some disk space to be used as extra memory in emergencies, called virtual memory, which is stored in a Page file/Swap file. The idea is that it is better for your computer to slow down than crash if you put too much data into memory. Virtual memory is incredibly slow because it really isn't optimized like the original file was on the disk. Given the large number of read/writes required in any calculation it will usually completely choke up your computer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, Solid State Drives (SSDs) are a lot faster to read/write than HDDs, so the advantages of in_memory may completely disappear if you have a fast SSD...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The number of features you are dealing with (130,000) is not particularly high, but it depends on the type and number of attributes you have associated with each feature. Obviously the amount of RAM you have will make a difference, and whether or not your setup is 64bit - this requires a 64bit operating system and ArcGIS 64bit background geoprocessing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 00:23:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370979#M29324</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2013-10-24T00:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370980#M29325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, I was working with arcpy.SelectLayerByAttribute_management, this that function have to be performed within ArcMap?&amp;nbsp; It seemed like once I changed my expression from the shapefile location to the layer name it worked.&amp;nbsp; Otherwise I received an error saying it can't select a feature class.&amp;nbsp; That would make sense though because it is Select LAYER, not Select Featureclass.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 15:33:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370980#M29325</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-10-24T15:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370981#M29326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried adding &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.env.workspace = "in_memory"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;near the top of my script, hoping it would put everything in memory, but it doesn't seem any faster.&amp;nbsp; I must have to change all my cursors and selections, too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 15:37:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370981#M29326</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-10-24T15:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370982#M29327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Holy Cow!&amp;nbsp; I copied the two layers I'm working with to new features "in_memory", then changed all layer references from the real layers to the memory layers, and instead of 10 hours, it's looking more like 45 minutes, assuming the RAM isn't exceeded.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 16:16:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370982#M29327</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-10-24T16:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370983#M29328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So it can run much much faster, but when I try to have my script create the layer copies to RAM, I get an error because the script doesn't add the layers to the TOC, so when the line setting the RAM layers as variables tries to run, it can't and it says the layer name is out of range.&amp;nbsp; Is there a special way to carry out a "CopyFeatures_management" and have it usable in the script?&amp;nbsp; Here's my layer set up:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mxd = arcpy.mapping.MapDocument("Current")
arcpy.env.workspace = "in_memory"
mapLyr1 = arcpy.mapping.ListLayers(mxd, "NEW_BiState_Grid400_IowaSP") [0]
mapLyr2 = arcpy.mapping.ListLayers(mxd, "NEW_BiState_Grid100_IowaSP") [0]
arcpy.CopyFeatures_management(mapLyr1, "in_memory\pyLyr1")
arcpy.CopyFeatures_management(mapLyr2, "in_memory\pyLyr2")
pyLyr1 = arcpy.mapping.ListLayers(mxd, "pyLyr1") [0]
pyLyr2 = arcpy.mapping.ListLayers(mxd, "pyLyr2") [0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried and to refresh the active view, but that didn't work.&amp;nbsp; This works fine it I copy and paste everything into the Python window instead of running it as a tool, although it's much slower.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370983#M29328</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2021-12-11T17:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370984#M29329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have a single slash in the destination layer name:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.CopyFeatures_management(mapLyr1, "in_memory&lt;STRONG&gt;\&lt;/STRONG&gt;pyLyr1")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You have a few options:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"in_memory\\pyLyr1"
"in_memory/pyLyr1"
r"in_memory\pyLyr1"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that doesn't help, you could try changing it to MakeFeatureLayer instead of &lt;/SPAN&gt;&lt;STRONG&gt;CopyFeatures&lt;/STRONG&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:23:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370984#M29329</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-12T16:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370985#M29330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using arcpy.MakeFeatureLayer_management() seems much faster than copying a layer, but when it's run as a script it still doesn't show up in the TOC and can't be referenced later either.&amp;nbsp; A single backslash seems to work fine in the Python Window, "in_memory\pyLyr1."&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 13:18:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370985#M29330</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-10-25T13:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370986#M29331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know it is an old post but worth mentioning that arcpy.Delete_mamangement("in_memory") does all for you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2016 00:59:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370986#M29331</guid>
      <dc:creator>FatihDur</dc:creator>
      <dc:date>2016-02-10T00:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Is in_memory Worth Using?</title>
      <link>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370987#M29332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the tip Faith, I'm going to use this today.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just fyi, yo may want to edit your post for a typo&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Fatih Dur wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it is an old post but worth mentioning that arcpy.Delete_mamangement("in_memory") does all for you.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Should be&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;​arcpy.Delete_management("in_memory")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: for what it's worth, at least in 10.3.1 &lt;A href="https://community.esri.com/migrated-users/7306"&gt;James Crandall&lt;/A&gt; 's script seems to be working more reliably for me....but then again, I still don't know that I'm using in_memory correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Feb 2016 16:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-in-memory-worth-using/m-p/370987#M29332</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-02-15T16:43:10Z</dc:date>
    </item>
  </channel>
</rss>

