Try our conversational search powered by Generative AI!

Large number of DDS objects in memory


Debugging a production site for very high memory consumption and found in the mem dump that there is a huge amount of dynamic datastore related objects kept in memory causing the site to recycle.

What operations on the dynamic data store causes stored objects to be loaded and kept in memory? Are all objects loaded into memory when calling DynamicDataStoreFactory.Instance.GetStore? Or does this happen when calling spesific methods on theDynamicDataStore ?


Nov 21, 2014 14:21
<p>I'm pretty sure that the GetStore method onle load store definition. Data objects are not loaded until you call Load or something. But they are just normal objects and can be GCed. Are there any references to them make them stick in memory?</p> <p>/Q</p>
Nov 21, 2014 16:29
<p>If you have memory dump try "GC Root"&nbsp;on one of the object to inspect a root entity that is holding a reference. If that's anything out of EPiServer - sounds like memory leak..</p>
Nov 24, 2014 22:16
<p>Agree, &nbsp;Load and LoadAll would load all objects into memory but there are no&nbsp;calls to these methods. Hower we come across several references to Find. Will that load everyting in memory or execute at backing store?&nbsp;</p> <p></p> <p>"GC root" for one of the objects (Namespace.MyObjectB)&nbsp;we have huge amounts of ( &lt; 300.000) looks like this</p> <p>&nbsp;</p> <p>(EPiServer.Data.Dynamic.Providers.ProviderCallContext)-&gt;&nbsp;</p> <p>(EPiServer.Data.Dynamic.EPiServerDynamicDataStore)-&gt;&nbsp;</p> <p>(System.Collections.Generic.Dictionary`2[[EPiServer.Data.Identity, EPiServer.Data],[System.Object, mscorlib]])-&gt;&nbsp;</p> <p>(System.Collections.Generic.Dictionary`2+Entry[[EPiServer.Data.Identity, EPiServer.Data],[System.Object, mscorlib]][])-&gt;&nbsp;</p> <p>(Namespace.MyObjectA)-&gt;&nbsp;</p> <p>(System.Collections.Generic.List`1[[Namespace.MyObjectB, Namespace]])-&gt;&nbsp;</p> <p>(System.Object[])-&gt;&nbsp;</p> <p>(Namespace.MyObjectB)</p> <p>&nbsp;&nbsp;</p> <p>Also have&nbsp;1264 instances of &nbsp;EPiServer.Data.Dynamic.EPiServerDynamicDataStore which I do not find logical.&nbsp;&nbsp;</p> <p></p> <p>Brownfield project so I do not have complete overview of the code yet. All tips are very welcome :)</p> <p></p> <p></p>
Nov 25, 2014 23:33
<p>Ok, can you give a snippet of code how you get instance of MyObjectB?</p>
Nov 26, 2014 7:09
<p>It goes something like this&nbsp;</p> <pre class="brush:csharp;auto-links:false;toolbar:false" contenteditable="false">//Do some other work SortedList&lt;string, MyObjectB&gt; myObjectBs= new SortedList&lt;string, MyObjectB&gt;(); foreach (string s in SomeProperty) { myObjectBs.Add(s, new MyObjectB(int.Parse(Request.QueryString["blablabla" + s].ToString()), int.Parse(Request.QueryString["otherblablabla_" + s].ToString()), SomeTab)); } // Do some other object initializations MyObjcectAProperty = new MyObjectA { //Set whole bunch of props MyObjectBs= myObjectBs, LanguageCode = CurrentPage.LanguageBranch }; //MyObjcectAProperty basically sets the new MyObjectA in the viewstate bag </pre> <p></p>
Nov 26, 2014 13:38
<p>Found another code fragment that might cause object graphs ralating to MyObjectA and MyObjectB to be loaded. At least Debug Diag points to this code wating on responses from the database. From the looks of the code some "upgrade" or remapping of the store seems to have been done.</p> <pre class="brush:html;auto-links:false;toolbar:false" contenteditable="false">DynamicDataStore store = DataUtility.GetStore("myStore", typeof(MyObjectA)); try { var myObjectA = store.Find&lt;MyObjectA&gt;("OrderCode", orderID).LastOrDefault(); if (myObjectA != null &amp;&amp; !string.IsNullOrEmpty(myObjectA .CategoryCode)) { moa = myObjectA ; } else moa = store.Find&lt;MyObjectA&gt;("OrderID", orderID).LastOrDefault(); } catch { moa = store.Find&lt;MyObjectA&gt;("OrderID", oldOrderID).LastOrDefault(); } try { if (string.IsNullOrEmpty(moa.CategoryCode)) moa = store.Find&lt;MyObjectA&gt;("OrderID", oldOrderID).LastOrDefault(); } catch { moa = store.Find&lt;MyObjectA&gt;("OrderID", oldOrderID).LastOrDefault(); } </pre> <p></p>
Nov 26, 2014 23:44
<p>Last catch clause looks weird (exactly as try) but not judging code here..</p> <p>What is definition of MyObject A/B? What happens if you explicitly enclose whole store in 'using' statement?</p>
Nov 27, 2014 5:30
<p>...The code <strong><em>is </em></strong>weird!! And very procedure oriented&nbsp;</p> <p>The whole block is enclosed by outher try catch &nbsp;with disposal of store in finaly block. "using" clause should have been used but it should serve same purpose.&nbsp;</p>
Edited, Dec 03, 2014 14:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.