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 ?
<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>
<p>If you have memory dump try "GC Root" 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>
<p>Agree, Load and LoadAll would load all objects into memory but there are no calls to these methods. Hower we come across several references to Find. Will that load everyting in memory or execute at backing store? </p>
<p></p>
<p>"GC root" for one of the objects (Namespace.MyObjectB) we have huge amounts of ( < 300.000) looks like this</p>
<p> </p>
<p>(EPiServer.Data.Dynamic.Providers.ProviderCallContext)-> </p>
<p>(EPiServer.Data.Dynamic.EPiServerDynamicDataStore)-> </p>
<p>(System.Collections.Generic.Dictionary`2[[EPiServer.Data.Identity, EPiServer.Data],[System.Object, mscorlib]])-> </p>
<p>(System.Collections.Generic.Dictionary`2+Entry[[EPiServer.Data.Identity, EPiServer.Data],[System.Object, mscorlib]][])-> </p>
<p>(Namespace.MyObjectA)-> </p>
<p>(System.Collections.Generic.List`1[[Namespace.MyObjectB, Namespace]])-> </p>
<p>(System.Object[])-> </p>
<p>(Namespace.MyObjectB)</p>
<p> </p>
<p>Also have 1264 instances of EPiServer.Data.Dynamic.EPiServerDynamicDataStore which I do not find logical. </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>
<p>It goes something like this </p>
<pre class="brush:csharp;auto-links:false;toolbar:false" contenteditable="false">//Do some other work
SortedList<string, MyObjectB> myObjectBs= new SortedList<string, MyObjectB>();
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>
<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<MyObjectA>("OrderCode", orderID).LastOrDefault();
if (myObjectA != null && !string.IsNullOrEmpty(myObjectA .CategoryCode))
{
moa = myObjectA ;
}
else
moa = store.Find<MyObjectA>("OrderID", orderID).LastOrDefault();
}
catch
{
moa = store.Find<MyObjectA>("OrderID", oldOrderID).LastOrDefault();
}
try
{
if (string.IsNullOrEmpty(moa.CategoryCode))
moa = store.Find<MyObjectA>("OrderID", oldOrderID).LastOrDefault();
}
catch
{
moa = store.Find<MyObjectA>("OrderID", oldOrderID).LastOrDefault();
}
</pre>
<p></p>
<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>
<p>...The code <strong><em>is </em></strong>weird!! And very procedure oriented </p>
<p>The whole block is enclosed by outher try catch with disposal of store in finaly block. "using" clause should have been used but it should serve same purpose. </p>
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 ?
Cheers