<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Clearing the cache</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Clearing the cache</description>
  <pubDate>Sun, 12 Apr 2026 21:38:55 -700</pubDate>
  <lastBuildDate>Thu, 19 Jul 2007 10:56:32 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=316</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Clearing the cache : A few additional observations.  1)...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=316&amp;PID=731#731</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 316<br /><strong>Posted:</strong> 19-Jul-2007 at 10:56am<br /><br /><FONT face=Arial color=#000080 size=2>A few additional observations.</FONT><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><SPAN =906455207-19072007></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN><SPAN =906455207-19072007>1) If you decide to remove from manager, you should know that this clears the entire Query Cache (not just the queries associated with the fetched type). That means that the PM&nbsp;no longer remembers that it queried anything. Subsequent queries go to database until the Q-cache is built back up.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN><SPAN =906455207-19072007>This is essential practice because removing from manager invalidates at least one query and it is near impossible to guess which other queries are affected. You removed a Company; that invalidates all Company queries but also Order queries because you might have queried for orders of a Company. And so on.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN><SPAN =906455207-19072007>There is an overload of the remove&nbsp;in which you tell the PM&nbsp;not to clear the Q-cache &#091;<FONT face="Lucida C&#111;nsole" color=#000000>Pm.RemoveEntities(IEnumerable, bool)</FONT>&#093;.</SPAN>&nbsp;<SPAN =906455207-19072007>&nbsp;You can manipulate the Q-cache directly too. These techniques are for special cases wherein you can be certain that no query is&nbsp;adversely affected by such removal or Q-cache manipulation.&nbsp;You&nbsp;cannot be certain in the scenario presented so I strong recommend that you do not use these techniques.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>2) I'm surprised you found such a large footprint. I'd like to see the case when you have time.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>3)&nbsp;Many customers anticipate problems with cache memory ... that never in fact arrive. As always with performance tuning, it helps to measure, measure, measure.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>4) The separate PM approach is the best and easiest for large collections of read-only data. For example, you might have a UI in which the user roots around in a huge Product Catalog. The user is profoundly unclear about what he wants and so retrieves an enormous number of products before settling on the three items he really wants.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>The catalog search UI relies upon a "Catalog PM" within the search UI. The floundering user's queries fill out this pm, not the Main Pm. You will ultimately discard the Catalog PM (or clear it).</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>This technique works fine for selecting data or even modifying that data while it resides in&nbsp;the Catalog PM.&nbsp;</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>Just remember to copy the selected/modified items from the Catalog PM to the Main PM before purging the Catalog PM; this copy&nbsp;is a simple, one-line statement.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>BTW, the search UI can assess the size of the Catalog PM and flush it only when it hits some max (after the user leaves the search&nbsp;module of course).</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>Observe that the Main PM's Q-cache is unaffected by these operations.</SPAN></o:p></SPAN></DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007><FONT color=#000080></FONT></SPAN></o:p></SPAN>&nbsp;</DIV><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007>5) I'm not sure it was clear: it is easy to clear the entity cache of an entire type; you don't have to do anything fancy with any queries; see <FONT face="Lucida C&#111;nsole" color=#000000>PM.RemoveEntities(Type, DataRowState).</FONT></SPAN></o:p></SPAN></DIV><DIV =Secti&#111;n1><DIV><DIV =Ms&#111;normal style="TEXT-ALIGN: center" align=center><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt"><DIV dir=ltr align=left><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><SPAN =906455207-19072007></SPAN></o:p></SPAN>&nbsp;</DIV></SPAN></FONT></DIV></DIV></DIV>]]>
   </description>
   <pubDate>Thu, 19 Jul 2007 10:56:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=316&amp;PID=731#731</guid>
  </item> 
  <item>
   <title>Clearing the cache : The PersistenceManager&#8217;s internal...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=316&amp;PID=730#730</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 316<br /><strong>Posted:</strong> 19-Jul-2007 at 10:52am<br /><br /><P =Ms&#111;normal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">The PersistenceManager’s internal datastore is a .NET dataset.&nbsp; We should have similar memory footprint for the data as .NET DataSet.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></P><P =Ms&#111;normal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;Here are the answers to your 3 questions:</o:p></SPAN></FONT></P><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p><OL style="MARGIN-TOP: 0in" =1><LI =Ms&#111;normal style="mso-list: l2 level1 lfo3"><FONT face=Arial size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">clear the orders cache so that it only ever holds the list of orders that relate to the selected customer, or<?:NAMESPACE PREFIX = U1 /><U1:P></U1:P></SPAN></FONT><SPAN lang=EN-AU><o:p></o:p></SPAN> </LI></OL><P =Ms&#111;normal><B><I><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: Arial">Yes. You can use Entity.RemoveFromManager or PersistenceManager.RemoveEntity overload for individual order removal from the PM’s cache.<o:p></o:p></SPAN></FONT></I></B></P><P =Ms&#111;normal><B><I><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: Arial">For multiple orders, you can query (order.CustomerId not equal to CurrentCustomer.Id etc) for a list of orders using a FetchStrategy of CacheOnly to obtain the list of orders to be removed.&nbsp; Then call PersistenceManager.RemoveEntities with the returned list.&nbsp;</SPAN></FONT></I></B><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P><OL style="MARGIN-TOP: 0in" =1 start=2><LI =Ms&#111;normal style="mso-list: l2 level1 lfo3"><FONT face=Arial size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">clear the cache of all orders when the form is closed, or<U1:P></U1:P></SPAN></FONT><SPAN lang=EN-AU><o:p></o:p></SPAN> </LI></OL><P =Ms&#111;normal><B><I><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: Arial">Same as item 1.</SPAN></FONT></I></B><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P><OL style="MARGIN-TOP: 0in" =1 start=3><LI =Ms&#111;normal style="mso-list: l2 level1 lfo3"><FONT face=Arial size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">clear the cache of all customers and orders when the form is closed?<U1:P></U1:P></SPAN></FONT><SPAN lang=EN-AU><o:p></o:p></SPAN> </LI></OL><P =Ms&#111;normal><B><I><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: Arial"><U1:P>You can do similar removal as in item 1.&nbsp; <o:p></o:p></SPAN></FONT></I></B></P><P =Ms&#111;normal><B><I><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: Arial">Alternatively, you may consider using a different PM for the target form.&nbsp; Create a new PM on Form_Load.&nbsp; Simply delete the PM on Form_Close.&nbsp; This way you main application’s PM is completely isolated from the Form’s PM and its cache data.<o:p></o:p></SPAN></FONT></I></B></P><P =Ms&#111;normal><B><I><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-STYLE: italic; FONT-FAMILY: Arial">Note: this technique only works well if none of the data changed inside the form is needed back in the main PM.</SPAN></FONT></I></B><FONT face=Arial color=navy size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p></o:p></SPAN></FONT></P><P =Ms&#111;normal><FONT face=Arial size=2><SPAN lang=EN-AU style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><U1:P>&nbsp;</U1:P></SPAN></FONT><SPAN lang=EN-AU><o:p></o:p></SPAN></P></U1:P></o:p></SPAN></FONT><P =Ms&#111;normal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Yes. You can remove business objects from the PM’s cache easily.&nbsp; See below…<o:p></o:p></SPAN></FONT></P>]]>
   </description>
   <pubDate>Thu, 19 Jul 2007 10:52:51 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=316&amp;PID=730#730</guid>
  </item> 
  <item>
   <title>Clearing the cache : We have been doing some tests...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=316&amp;PID=729#729</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=20" rel="nofollow">Customer</a><br /><strong>Subject:</strong> 316<br /><strong>Posted:</strong> 19-Jul-2007 at 10:46am<br /><br /><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman">We have been doing some tests on the amount of memory consumed when DevForce loads back entities and it’s quite significant. For example, a 25MB table in SQL server consumes 100MB when using a plain .Net DataSet and about 200MB when using a DevForce entity cache (note: the numbers are approximate). Our application will not typically load back all of this data at once, but in a user session that lasts for a number of hours it’s quite possible that they’ll gradually trigger the loading of a large amount of data back to the client, and therefore consume a lot of memory.<?:NAMESPACE PREFIX = U1 /><U1:P></U1:P><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman"><U1:P>&nbsp;</U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman">We therefore want to use a strategy of clearing out child entity lists that are no longer needed. I fully understand that we lose any subsequent performance advantage that cached data would provide, but a client session that incrementally consumes memory without releasing it as a user steps through data will be a significant problem for us.<U1:P></U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman"><U1:P>&nbsp;</U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman">The typical scenario would be something like this (and I’ll revert to the old customer-order scenario to explain it).<U1:P></U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman"><U1:P>&nbsp;</U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman">A form has two grids. The top grid has a list of customers. The bottom grid has a list of related orders for the selected customer.<U1:P></U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman"><U1:P>&nbsp;</U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman">As the user steps through each customer, the related orders are loaded back. As more and more orders are retrieved, more and more memory is consumed but not released.<U1:P></U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman"><U1:P>&nbsp;</U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman">Is it possible to:<U1:P></U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><FONT size=3><FONT face="Times New Roman"><U1:P>&nbsp;</U1:P><o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN lang=EN-AU style="mso-ansi-: EN-AU">(1) Clear the orders cache so that it only ever holds the list of orders that relate to the selected customer, or<U1:P></U1:P></SPAN><SPAN lang=EN-AU> </SPAN><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN lang=EN-AU style="mso-ansi-: EN-AU">(2) Clear the cache of all orders when the form is closed, or<U1:P></U1:P></SPAN><SPAN lang=EN-AU> </SPAN><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN lang=EN-AU style="mso-ansi-: EN-AU">(3) Clear the cache of all customers and orders when the form is closed?<U1:P></U1:P></SPAN><SPAN lang=EN-AU> </SPAN><SPAN lang=EN-AU style="mso-ansi-: EN-AU"><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P>]]>
   </description>
   <pubDate>Thu, 19 Jul 2007 10:46:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=316&amp;PID=729#729</guid>
  </item> 
 </channel>
</rss>