<?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: Memory usage for ArcMap - System.OutOfMemoryException //c# in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678088#M18154</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'll address the methods one at a time as needed. I really don't understand why you are interested in the memory usage totals. You should be concerned with &lt;STRONG&gt;what objects&lt;/STRONG&gt; are using the most memory. Anyway, here is the first method:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private static void GetSelectedFeatures(IFeatureLayer featLayer, string layerName, Dictionary&amp;lt;string, string&amp;gt; dc)
{
 ICursor cursor = null;
 IRow row = null;
 try
 {
&amp;nbsp; cursor = Utilities.GetCursor(featLayer);
&amp;nbsp; row = cursor.NextRow();
&amp;nbsp; while (row != null)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; string nadrzedny = Utilities.GetStringValueFromField(row, FIELD_NAME_NADRZEDNY);
&amp;nbsp;&amp;nbsp; string uniqueNR = Utilities.GetStringValueFromField(row, FIELD_NAME_UNIKALNY);
&amp;nbsp;&amp;nbsp; if (!dc.ContainsKey(nadrzedny))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dc.Add(nadrzedny, uniqueNR);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // release each instance of row&amp;nbsp; 
&amp;nbsp;&amp;nbsp; Marshal.ReleaseComObject(row);
&amp;nbsp;&amp;nbsp; // set it to null in case the next line throws an exception
&amp;nbsp;&amp;nbsp; // don't want to release it a second time in the finally-block
&amp;nbsp;&amp;nbsp; row = null; 
&amp;nbsp;&amp;nbsp; row = cursor.NextRow();
&amp;nbsp; }
 }
 finally
 {
&amp;nbsp; // row should be null unless an exception occurred, in which case
&amp;nbsp; // the last allocated instance of row should still be released
&amp;nbsp; if( row != null )
&amp;nbsp;&amp;nbsp; Marshal.ReleaseComObject(row);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; Marshal.ReleaseComObject(cursor);
 }
 
 GetFinalListOfFeatures(layerName);
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you post the entire class that contains these methods? It looks like there are lots of class fields (globals) that there isn't any context for in the sample you provided. You should definitely avoid class fields and particularly static class fields because the may cause objects to stick around longer than necessary. Any object stored in a static class field in a static class is going to stick around until the AppDomain shuts down, which happens when the process is torn down.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:35:10 GMT</pubDate>
    <dc:creator>JasonPike</dc:creator>
    <dc:date>2021-12-12T04:35:10Z</dc:date>
    <item>
      <title>Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678082#M18148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi the problem is common as far as I know from reading post from this and other forums(memory usage for arcgis). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm developing a add-in for ArcMap that checks electricity flow in Geometric Network. I've created a loop for over 14 000 start points for my analysis. I'm using Utility Network Analyst and the FindFlowElements method, the algorithm is preety simple:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Get Geometric Network IDs for starting point(FCID, FID, subID)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Configure Geometric Network&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. FindFlowElements -&amp;gt; as a result i get junctionEIDs and edgeEIDs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Create selection from the result&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. Analyze the selection &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. Log info&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7. Clearing the result&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8. Clearing the flags for network utility&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;9. Clearing the selection for map&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10. Partial refresh&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;11. Marshal.FinalReleaseComObject(traceFlowSolver); // testing it because of the out of memory exception&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and again from the point 1 for next point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So when we tested this we encountered a lot of errors. I have the log info we are writing to txt file it will be easier to illustrate the problem with example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;INFO 2013-03-19 12:56:12,302 â?? Called FindFlowElements method 1374 time(s)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Number of objects in List&amp;lt;T&amp;gt; SN = 1316, memory usage = 0,06808 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Number of objects in List&amp;lt;T&amp;gt; nN = 10068, memory usage = 0,43913 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Station number 7545 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Process name: ArcMap -&amp;gt; memory use 834,5586 MB || GC TotalMemory -&amp;gt; 80,0527 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Processes list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IEXPLORE ||memory use-&amp;gt; 31,6836 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FSM32 ||memory use-&amp;gt; 15,6992 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SVCHOST ||memory use-&amp;gt; 26,4336 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;EXPLORER ||memory use-&amp;gt; 85,4766 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SMSVCHOST ||memory use-&amp;gt; 37,5313 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DSTERMSERV ||memory use-&amp;gt; 27,0664 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FSSM32 ||memory use-&amp;gt; 167,2422 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SVCHOST ||memory use-&amp;gt; 48,6758 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SVCHOST ||memory use-&amp;gt; 82,5117 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FSHDLL32 ||memory use-&amp;gt; 52,4531 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BCU ||memory use-&amp;gt; 85,0273 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ORACLE ||memory use-&amp;gt; 771,1250 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLWOW64 ||memory use-&amp;gt; 15,6484 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IEXPLORE ||memory use-&amp;gt; 15,7031 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ARCMAP ||memory use-&amp;gt; 964,2070 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SEARCHINDEXER ||memory use-&amp;gt; 50,6445 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TNSLSNR ||memory use-&amp;gt; 36,6602 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WINWORD ||memory use-&amp;gt; 22,3398 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FSGK32 ||memory use-&amp;gt; 15,4453 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SOFFICE.BIN ||memory use-&amp;gt; 16,2188 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AUDIODG ||memory use-&amp;gt; 18,5859 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IEXPLORE ||memory use-&amp;gt; 19,3359 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPOOLSV ||memory use-&amp;gt; 17,4063 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WMPNETWK ||memory use-&amp;gt; 30,1172 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SVCHOST ||memory use-&amp;gt; 29,7500 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SVCHOST ||memory use-&amp;gt; 234,8750 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DWM ||memory use-&amp;gt; 45,6406 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SVCHOST ||memory use-&amp;gt; 25,8594 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CONNECT.SERVICE.CONTENTSERVICE ||memory use-&amp;gt; 51,8594 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Memory usage sum = 2911,0120 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=================================================================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;INFO 2013-03-19 12:56:14,954 â?? Called FindFlowElements method 1375 times&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Number of objects in List&amp;lt;T&amp;gt; SN = 1316, memory usage = 0,06808 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Number of objects in List&amp;lt;T&amp;gt; nN = 10072, memory use = 0,43931 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Station number 7397 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Process name: ArcMap -&amp;gt; memory use 838,7539 MB || GC TotalMemory -&amp;gt; 84,8050 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Processes list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Memory usage sum = 2899,1410 MB&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The FindFlowElementos method was called 1375 times(14 000 expected...) and ArcMap already uses ~840 MB(when it reaches ~2GB arcmap throws an error) of memory and it's growing with every iteration. Sometimes it drops with few MB but no to often so i will propably have to do the cleaning manually, but the question is how?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will explain now how i calculated/got the memory usage:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1.For ArcMap:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
private const float mbyte = 1048576;
Process proc = Process.GetCurrentProcess();
string privMemSize = (proc.PrivateMemorySize64 / mbyte).ToString("0.0000");
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2.For Garbage Collector:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
string gcTotalMem = (GC.GetTotalMemory(false) / mbyte).ToString("0.0000");
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3.Memory usage for Lists&amp;lt;T&amp;gt; I'm calculating with method I took from StackExchange:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
private static string GetObjectSize(object TestObject)
{
 try
 {
&amp;nbsp; BinaryFormatter bf = new BinaryFormatter();
&amp;nbsp; MemoryStream ms = new MemoryStream();
&amp;nbsp; byte[] Array;
&amp;nbsp; bf.Serialize(ms, TestObject);
&amp;nbsp; Array = ms.ToArray();
&amp;nbsp; return ((float)Array.Length / mbyte).ToString("0.00000");
 }
 catch (Exception ex)
 {
&amp;nbsp; log.Error("========================================================================\n"
&amp;nbsp;&amp;nbsp; +ex.Message + "\n" + ex.StackTrace + "\n"
&amp;nbsp;&amp;nbsp; + "========================================================================\n");
&amp;nbsp; return "error";
 }
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The question is how I can handle the increasing memory usage for ArcMap.exe? Anyone got idea?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:46:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678082#M18148</guid>
      <dc:creator>MarcinDruzgala</dc:creator>
      <dc:date>2021-12-12T16:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678083#M18149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcMap is a 32 bit process.&amp;nbsp; By default it can access 2 ** 32 / 2 bytes of memory.&amp;nbsp; If you run it on a 64 bit machine with a 64 bit OS then it can access 2 ** 32 bytes of memory.&amp;nbsp; In essence, you get 4 GB instead of 2 GB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't see where you specified what version of ArcMap you are using.&amp;nbsp; In earlier versions you have to literally set the large address aware bit on ArcMap.exe in order to make this work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 15:20:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678083#M18149</guid>
      <dc:creator>RichardWatson</dc:creator>
      <dc:date>2013-03-19T15:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678084#M18150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What Richard is saying about 32 bit and large address aware is very true.&amp;nbsp; The obvious question then is why is your application taking so much memory and how can you reduce it.&amp;nbsp; Without seeing the code of the loop it is hard to point to one thing or another.&amp;nbsp; Marshall com release must be done on any cursors and usually on the features or rows in the loop too.&amp;nbsp; I don't know if you use recycling on the cursor or if you limit the fields.&amp;nbsp; You also don't mention the type of database (large selections on an enterprise gdb are done on the database.)&amp;nbsp; If you can reduce the amount the memory grows per iteration, you should be able to process the entire dataset.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 16:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678084#M18150</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2013-03-19T16:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678085#M18151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Code examples would help us to identify the problem. Also, you can use tools like CLR Profiler, UMDH, and LeakDiag to quickly identify which objects are consuming the most memory. Once you know which ones are consuming the most memory, you can focus your attention on getting them released properly. Or, you can do what I do, and make sure everything is released immediately after it is no longer needed--this approach is error prone, so be very careful if you try it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 16:19:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678085#M18151</guid>
      <dc:creator>JasonPike</dc:creator>
      <dc:date>2013-03-19T16:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678086#M18152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for replying, my mistake that i didn't post the machine specification. We are testing this utility on two PC:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Windows Server 2008 R2 Foundation 64 bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Intel Xeon X3430 @ 2.40 GHz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8 GB RAM &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.Windows 7 Proffessional 64 bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Intel i7-2600K @ 3.40GHz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8 GB RAM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On both PC the version of ArcGIS is 10.0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; ArcMap is a 32 bit process. By default it can access 2 ** 32 / 2 bytes of memory. If you run it on a 64 bit machine with a 64 bit OS then it can access 2 ** 32 bytes of memory. In essence, you get 4 GB instead of 2 GB.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yep I've read that arcmap is native 32-bit process and it can use 4GB of ram BUT still I dont think in that process I need so much memory..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In case of releasing the COM object, we are doing it every time when we use a COM object with ReleaseComObject method. Since we wanted to fasten the application and shorten the time needed to analyze so much data at the beggining we are creating dictionaries from feature attributes table(of course not all attributes, just the one we need). The code sample you are asking for I'm attaching in txt file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did today another hard test with this utility and something really weird is happening with ArcMap, I will show you few Inof's from log file(noone else was using any of the PC's in our office):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;INFO 2013-03-19 08:18:57,083 â?? Called FindFlowElements method 3213 time(s)
Process name: ArcMap -&amp;gt; memory usage 1588,7460 MB || GC TotalMemory -&amp;gt; 264,3199 MB

INFO 2013-03-19 08:19:00,717 â?? Called FindFlowElements method 3214 time(s)
Process name: ArcMap -&amp;gt; memory usage 1492,2500 MB || GC TotalMemory -&amp;gt; 176,0005 MB

INFO 2013-03-19 08:19:04,430 â?? Called FindFlowElements method 3215 time(s)
Process name: ArcMap -&amp;gt; memory usage 1611,6560 MB || GC TotalMemory -&amp;gt; 297,3569 MB&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Only 7seconds and so much difference in memory usage...that's weird isn't it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Later get's better;) -&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;INFO 2013-03-19 10:18:29,839 â?? Called FindFlowElements method 4823 time(s)
Process name: ArcMap -&amp;gt; memory usage 2010,1130 MB || GC TotalMemory -&amp;gt; 221,0689 MB

INFO 2013-03-19 10:18:40,649 â?? Called FindFlowElements method 4824 time(s)
Process name: ArcMap -&amp;gt; memory usage &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;-1884,5430 MB&lt;/SPAN&gt; || GC TotalMemory -&amp;gt; 423,0786 MB

INFO 2013-03-19 10:18:44,892 â?? Called FindFlowElements method 4825 time(s)
Process name: ArcMap -&amp;gt; memory usage &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;-1682,0350 MB&lt;/SPAN&gt; || GC TotalMemory -&amp;gt; 620,8250 MB

INFO 2013-03-19 10:18:49,229 â?? Called FindFlowElements method 4826 time(s)
Process name: ArcMap -&amp;gt; memory usage 1976,2620 MB || GC TotalMemory -&amp;gt; 183,4406 MB&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Funny(or maybe it's normal??)? At the same time notice the increase of Garbage Collector managed memory and 5 sec later it's down over 400MB. I'm not the expert in memory managing but it looks weird.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you got any idea about this please share you knowledge I'm very curious about this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:35:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678086#M18152</guid>
      <dc:creator>MarcinDruzgala</dc:creator>
      <dc:date>2021-12-12T04:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678087#M18153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Thanks for replying, my mistake that i didn't post the machine specification. We are testing this utility on two PC:&amp;nbsp; &lt;BR /&gt;1. Windows Server 2008 R2 Foundation 64 bit&amp;nbsp; &lt;BR /&gt;Intel Xeon X3430 @ 2.40 GHz&amp;nbsp; &lt;BR /&gt;8 GB RAM&amp;nbsp;&amp;nbsp; &lt;BR /&gt;2.Windows 7 Proffessional 64 bit&amp;nbsp; &lt;BR /&gt;Intel i7-2600K @ 3.40GHz&amp;nbsp; &lt;BR /&gt;8 GB RAM&amp;nbsp; &lt;BR /&gt;On both PC the version of ArcGIS is 10.0.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;Yep I've read that arcmap is native 32-bit process and it can use 4GB of ram BUT still I dont think in that process I need so much memory..&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;In case of releasing the COM object, we are doing it every time when we use a COM object with ReleaseComObject method. Since we wanted to fasten the application and shorten the time needed to analyze so much data at the beggining we are creating dictionaries from feature attributes table(of course not all attributes, just the one we need). The code sample you are asking for I'm attaching in txt file.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;I did today another hard test with this utility and something really weird is happening with ArcMap, I will show you few Inof's from log file(noone else was using any of the PC's in our office):&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;INFO 2013-03-19 08:18:57,083 â?? Called FindFlowElements method 3213 time(s)
Process name: ArcMap -&amp;gt; memory usage 1588,7460 MB || GC TotalMemory -&amp;gt; 264,3199 MB

INFO 2013-03-19 08:19:00,717 â?? Called FindFlowElements method 3214 time(s)
Process name: ArcMap -&amp;gt; memory usage 1492,2500 MB || GC TotalMemory -&amp;gt; 176,0005 MB

INFO 2013-03-19 08:19:04,430 â?? Called FindFlowElements method 3215 time(s)
Process name: ArcMap -&amp;gt; memory usage 1611,6560 MB || GC TotalMemory -&amp;gt; 297,3569 MB&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;Only 7seconds and so much difference in memory usage...that's weird isn't it?&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Later get's better;) -&amp;gt;&amp;nbsp; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;INFO 2013-03-19 10:18:29,839 â?? Called FindFlowElements method 4823 time(s)
Process name: ArcMap -&amp;gt; memory usage 2010,1130 MB || GC TotalMemory -&amp;gt; 221,0689 MB

INFO 2013-03-19 10:18:40,649 â?? Called FindFlowElements method 4824 time(s)
Process name: ArcMap -&amp;gt; memory usage &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;-1884,5430 MB&lt;/SPAN&gt; || GC TotalMemory -&amp;gt; 423,0786 MB

INFO 2013-03-19 10:18:44,892 â?? Called FindFlowElements method 4825 time(s)
Process name: ArcMap -&amp;gt; memory usage &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;-1682,0350 MB&lt;/SPAN&gt; || GC TotalMemory -&amp;gt; 620,8250 MB

INFO 2013-03-19 10:18:49,229 â?? Called FindFlowElements method 4826 time(s)
Process name: ArcMap -&amp;gt; memory usage 1976,2620 MB || GC TotalMemory -&amp;gt; 183,4406 MB&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;Funny(or maybe it's normal??)? At the same time notice the increase of Garbage Collector managed memory and 5 sec later it's down over 400MB. I'm not the expert in memory managing but it looks weird.&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;If you got any idea about this please share you knowledge I'm very curious about this.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll address the methods one at a time as needed. I really don't understand why you are interested in the memory usage totals. You should be concerned with &lt;/SPAN&gt;&lt;STRONG&gt;what objects&lt;/STRONG&gt;&lt;SPAN&gt; are using the most memory. Anyway, here is the first method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private static void GetSelectedFeatures(IFeatureLayer featLayer, string layerName, Dictionary&amp;lt;string, string&amp;gt; dc)
{
 ICursor cursor = null;
 IRow row = null;
 try
 {
&amp;nbsp; cursor = Utilities.GetCursor(featLayer);
&amp;nbsp; row = cursor.NextRow();
&amp;nbsp; while (row != null)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; string nadrzedny = Utilities.GetStringValueFromField(row, FIELD_NAME_NADRZEDNY);
&amp;nbsp;&amp;nbsp; string uniqueNR = Utilities.GetStringValueFromField(row, FIELD_NAME_UNIKALNY);
&amp;nbsp;&amp;nbsp; if (!dc.ContainsKey(nadrzedny))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dc.Add(nadrzedny, uniqueNR);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // release each instance of row&amp;nbsp; 
&amp;nbsp;&amp;nbsp; Marshal.ReleaseComObject(row);
&amp;nbsp;&amp;nbsp; // set it to null in case the next line throws an exception
&amp;nbsp;&amp;nbsp; // don't want to release it a second time in the finally-block
&amp;nbsp;&amp;nbsp; row = null; 
&amp;nbsp;&amp;nbsp; row = cursor.NextRow();
&amp;nbsp; }
 }
 finally
 {
&amp;nbsp; // row should be null unless an exception occurred, in which case
&amp;nbsp; // the last allocated instance of row should still be released
&amp;nbsp; if( row != null )
&amp;nbsp;&amp;nbsp; Marshal.ReleaseComObject(row);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; Marshal.ReleaseComObject(cursor);
 }
 
 GetFinalListOfFeatures(layerName);
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:35:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678087#M18153</guid>
      <dc:creator>JasonPike</dc:creator>
      <dc:date>2021-12-12T04:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678088#M18154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'll address the methods one at a time as needed. I really don't understand why you are interested in the memory usage totals. You should be concerned with &lt;STRONG&gt;what objects&lt;/STRONG&gt; are using the most memory. Anyway, here is the first method:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;private static void GetSelectedFeatures(IFeatureLayer featLayer, string layerName, Dictionary&amp;lt;string, string&amp;gt; dc)
{
 ICursor cursor = null;
 IRow row = null;
 try
 {
&amp;nbsp; cursor = Utilities.GetCursor(featLayer);
&amp;nbsp; row = cursor.NextRow();
&amp;nbsp; while (row != null)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; string nadrzedny = Utilities.GetStringValueFromField(row, FIELD_NAME_NADRZEDNY);
&amp;nbsp;&amp;nbsp; string uniqueNR = Utilities.GetStringValueFromField(row, FIELD_NAME_UNIKALNY);
&amp;nbsp;&amp;nbsp; if (!dc.ContainsKey(nadrzedny))
&amp;nbsp;&amp;nbsp;&amp;nbsp; dc.Add(nadrzedny, uniqueNR);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; // release each instance of row&amp;nbsp; 
&amp;nbsp;&amp;nbsp; Marshal.ReleaseComObject(row);
&amp;nbsp;&amp;nbsp; // set it to null in case the next line throws an exception
&amp;nbsp;&amp;nbsp; // don't want to release it a second time in the finally-block
&amp;nbsp;&amp;nbsp; row = null; 
&amp;nbsp;&amp;nbsp; row = cursor.NextRow();
&amp;nbsp; }
 }
 finally
 {
&amp;nbsp; // row should be null unless an exception occurred, in which case
&amp;nbsp; // the last allocated instance of row should still be released
&amp;nbsp; if( row != null )
&amp;nbsp;&amp;nbsp; Marshal.ReleaseComObject(row);
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; Marshal.ReleaseComObject(cursor);
 }
 
 GetFinalListOfFeatures(layerName);
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you post the entire class that contains these methods? It looks like there are lots of class fields (globals) that there isn't any context for in the sample you provided. You should definitely avoid class fields and particularly static class fields because the may cause objects to stick around longer than necessary. Any object stored in a static class field in a static class is going to stick around until the AppDomain shuts down, which happens when the process is torn down.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:35:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678088#M18154</guid>
      <dc:creator>JasonPike</dc:creator>
      <dc:date>2021-12-12T04:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678089#M18155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot Jason for your tips, I will try your approach about releasing COM objects -&amp;gt; I thought that if I release only the ICursor object the IRow object would be destroyed too, but seems like I was wrong. Next thing I'm apparently wrong about is that I thought releasing COM objects inside a loop would be an error. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;About global static objects you are right I've got 'few' of them...I'm aware I should propably re-write the whole utility. I've started to write it few months ago(5-6), then I had like 4 month pause and now when I'm back with it I just want to sit down and re-write the whole thing but there is no time. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will change few things, run next test and I will post the results here.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 13:51:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678089#M18155</guid>
      <dc:creator>MarcinDruzgala</dc:creator>
      <dc:date>2013-03-20T13:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678090#M18156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Code examples would help us to identify the problem. Also, you can use tools like CLR Profiler, UMDH, and LeakDiag to quickly identify which objects are consuming the most memory. Once you know which ones are consuming the most memory, you can focus your attention on getting them released properly. Or, you can do what I do, and make sure everything is released immediately after it is no longer needed--this approach is error prone, so be very careful if you try it.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok I've used the LeakDiag to investigate the memory usage problem but honestly the result doesn't say much to me. Can you please take a look at them? I'm attaching xml files in .rar so if you could take a look at them at least in the LDGrapher application. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did tests for 2 types of Memory allocators:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1.Windows Heap Allocator (4 logs, logged every 5 minutes)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.COM Allocator (same: 4 logs/5min interval)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcMap was already using ~1,8 GB of RAM.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm attaching the graphs I got from loading this logs into LDGrapher with parameters opened for the most memory consuming lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]22872[/ATTACH][ATTACH=CONFIG]22873[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MDruzgala&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 10:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678090#M18156</guid>
      <dc:creator>MarcinDruzgala</dc:creator>
      <dc:date>2013-03-22T10:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678091#M18157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Those logs are missing a lot of information that we need. Have you set up your symbol path?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In LeakDiag, you use the following steps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Tools -&amp;gt; Options&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Set the symbol search path to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;cache*C:\dev\symbols;SRV*C:\dev\symbols*http://msdl.microsoft.com/download/symbols;SRV*C:\dev\symbols*http://downloads2.esri.com/Support/symbols/&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Check the "Resolve symbols when logging."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4) Change the max stack depth to 32.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For most other tools (UMDH, WinDbg, etc.) you add a User Environment Variable called _NT_SYMBOL_PATH and set its value to the search path described above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm afraid the ArcMap will choke LeakDiag with these settings--it works great if you can create a small test project that reproduces the problem, though. I typically use UMDH if I have no choice but to use full-blown ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LeakDiag and UMDH give us a good look at unmanaged code--it is showing the managed code's effects indirectly, but a log from CLRProfiler would give us a different perspective that may also be useful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally, what I was able to gather from you logs was that there seems to be a lot of unmanaged strings allocated. Before you log anything else, you need to add a system environment variable called OANOCACHE and set its value to 1 to disable string caching so that we get an accurate picture of what code is responsible for their allocation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 13:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678091#M18157</guid>
      <dc:creator>JasonPike</dc:creator>
      <dc:date>2013-03-22T13:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678092#M18158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok Jason I did what you've told me to do and here is the result. I hope this time everything is ok : &amp;gt; Could you please take a look at this logs?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The CLRPRofiler can't connect to arcmap process(?). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"clr profiler waiting for application to start common language runtime" even if i run my add-in nothing happens.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UMDH - this will take much more time for me to understand this. Will give it a shot maybe later if I don't find the solution now with LeakDiag.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 12:20:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678092#M18158</guid>
      <dc:creator>MarcinDruzgala</dc:creator>
      <dc:date>2013-03-25T12:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Memory usage for ArcMap - System.OutOfMemoryException //c#</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678093#M18159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Ok Jason I did what you've told me to do and here is the result. I hope this time everything is ok : &amp;gt; Could you please take a look at this logs?&lt;BR /&gt;&lt;BR /&gt;The CLRPRofiler can't connect to arcmap process(?). &lt;BR /&gt;"clr profiler waiting for application to start common language runtime" even if i run my add-in nothing happens.&lt;BR /&gt;&lt;BR /&gt;UMDH - this will take much more time for me to understand this. Will give it a shot maybe later if I don't find the solution now with LeakDiag.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for your help!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We still seem to be limited to a stack depth of 5. Did you change the max stack depth to 32? It does look like you got some of the symbols resolved though. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to know what FeatureDataElements.dll contains. More importantly, we need to know what your code is using from FeatureDataElements.dll. That is one place that needs to be more particular about explicitly releasing COM objects. If we had more stack information, we could probably see what calls your code was making that ended up using the DLL. Another thing you can try is removing FeatureDataElements.dll from your project references (if it is in your project references) and rebuilding to see what lines of code no longer compile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I see a stack like the one below, I become concerned that there might be a memory leak in ESRI's product:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;AfCore.dll!BString__BString
GpObjects.dll!GPSchemaBase__operator=
GpObjects.dll!GPSchemaBase__operator=
DECoreLib.dll!GPValue__Clone
GeoprocessingLib.dll!GPFeatureLayerBase__Assign&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You indicated in a response to one of my posts in a different thread that you'd like to learn as much as possible about this. Check out the link below to better understand why this makes me suspicious:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/xda6xzx7(v=vs.80).aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/xda6xzx7(v=vs.80).aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like an object is cloned, which allocates a BSTR that isn't being released. Did you set the OANOCACHE to 1 in your environment variables? If not, we can't trust this stack, but if you did, we should pursue this as well. Where is your code assigning a FeatureLayer? If the object has been properly released and is no longer used within the system, we shouldn't see that stack.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next up, we have something that is using FdaCore.dll, which in turn is creating a string that is still in memory at the point you last marked. Again, I really need to see more of the stack so we can determine how your code causes this to be called in the first place. I have the same concern here as I do with the previous one: someone allocated a string and didn't release it. Either you have a pointer the object that is keeping it in memory, or you are disconnected from the object and it didn't clean up after itself properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;MSVCR90.dll!malloc
MSVCR90.dll!operator new
AfCore.dll!String__CreateStringData
AfCore.dll!String__String
FdaCore.dll!??????&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is another stack that we need to understand how your code is causing to occur. I'm not familiar with NetEngine80.dll, but a few Google searches suggest that it may be related to a doubly-linked list being maintained by one of the ESRI objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;MSVCR90.dll!malloc
NetEngine80.dll!NE__IDCache__IsEqual3Tuple
NetEngine80.dll!NE__List&amp;lt;NE__LRUNode&amp;gt;__Disconnect
NetEngine80.dll!NE__List&amp;lt;NE__LRUNode&amp;gt;__Disconnect
NetEngine80.dll!NE__List&amp;lt;NE__LRUNode&amp;gt;__Disconnect&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As for the CLRProfiler problem you're seeing, you need to get the version that matches the .NET version that your code uses. Also, you'll want to use the x86 version, even if you have an x64 operating system. Regardless of what it reports about connecting, try to create some logs and see if it collected anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can't get LeakDiag to capture stacks larger than 5 deep, it is time to move on to UMDH. You can see from what I've written above that the granularity is only good for hints, but we want specifics, if possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can create a small project that reproduces the issue and post it on the forum, I'd be happy to analyze it for you. Otherwise, continue to analyze your code based on the hints and try to identify the calls your code is making that result in the memory allocations from LeakDiag.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:35:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-usage-for-arcmap-system/m-p/678093#M18159</guid>
      <dc:creator>JasonPike</dc:creator>
      <dc:date>2021-12-12T04:35:13Z</dc:date>
    </item>
  </channel>
</rss>

