<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET Memory Leak: Byte arrays rooted in System.Security.Policy.Evidence</title><link>http://blogs.msdn.com/tess/archive/2008/06/25/asp-net-memory-leak-byte-arrays-rooted-in-system-security-policy-evidence.aspx</link><description>Today I got a question from a reader (Chris) about a memory leak they are seeing in their application When we do a '!dumpheap -min 85000 -type Byte[]' we can see 100s of byte array objects using up ~545MB of memory. A majority of the objects are the same</description><dc:language>sv-SE</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: ASP.NET Memory Leak: Byte arrays rooted in System.Security.Policy.Evidence</title><link>http://blogs.msdn.com/tess/archive/2008/06/25/asp-net-memory-leak-byte-arrays-rooted-in-system-security-policy-evidence.aspx#8673311</link><pubDate>Tue, 01 Jul 2008 00:41:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8673311</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Tess,&lt;/p&gt;
&lt;p&gt;Thanks for post from my email but our solution ended up being a little different. First, we were already running SP1. And second, Our 4.5MB assembly was hosting a lot of our code, and all of our [WebMethod]s. We did a little Reflecting and found out that the &amp;quot;Executing Assembly&amp;quot; will be copied into memory by the Evidence class as part of CAS on every web service request, and remain in memory for the length of the request. &lt;/p&gt;
&lt;p&gt;We moved our WebMethods out to a new assembly and changed our .asmx files to point to this new assembly. Our new WebMethods only assembly is only 300K and every method just calls the same old code in the big assembly and everything is working normally now. Hope this makes sense and is a valid solution. &lt;/p&gt;
&lt;p&gt;Thanks for the help,&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
</description></item><item><title>re: ASP.NET Memory Leak: Byte arrays rooted in System.Security.Policy.Evidence</title><link>http://blogs.msdn.com/tess/archive/2008/06/25/asp-net-memory-leak-byte-arrays-rooted-in-system-security-policy-evidence.aspx#8800309</link><pubDate>Fri, 01 Aug 2008 18:13:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8800309</guid><dc:creator>John</dc:creator><description>&lt;p&gt;I've found that with sp1 (on our local machines and our servers) &amp;nbsp;whenever a web service request is made, &amp;nbsp;the application will store the same assembly 4 times in the manged heap as byte arrays. &amp;nbsp;This is very confusing. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;To rule out any faults in the application, I created a new web app. &amp;nbsp;Added a single web service. &amp;nbsp;Used the &amp;quot;hello world&amp;quot; example that gets generated automatically when creating a new web service. &amp;nbsp;To make it easier for me to differentiate the byte arrays, I changed the &amp;quot;hello world&amp;quot; string to a string builder containing a long lorem ipsum. &amp;nbsp;I then just returned the toString() of the string builder. &amp;nbsp;Built the application, ran it. &amp;nbsp;Did an dump right before I ran the webservice(just used GET) and another right after. &amp;nbsp;WinDbg showed 4 identical byte arrays containing the webservice assembly. &amp;nbsp;I guess my question is, have you or anyone else seen this behavior before? &amp;nbsp;Any idea what could be causing it. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;At first I thought it was an awfully big coincidence that there are Soap, Soap 1.2, Get, and Post(4 total). &amp;nbsp;After shutting off Soap and Soap 1.2 in the web config, it still stored 4 assemblies. &amp;nbsp;I'm out of ideas. &amp;nbsp;This has caused me many hours of headache on our production boxes as our web service assembly was well over 300kb. &amp;nbsp;Our application hosts many templated sites which all will cause 4 of these assemblies to be build. &amp;nbsp;So, 300kb x 4 x 1000 sites = out of memory.&lt;/p&gt;
&lt;p&gt;I have modified the structure and split out some of the related web services into separate assemblies. &amp;nbsp;This has dropped most of them down to below the LOH threshold. &amp;nbsp;The application is constantly under development and I could see a developer adding more code to some of those assemblies potentially bringing them back into the LOH. &amp;nbsp;I guess I'm just venting, but I would appreciate it if some of you could try to reproduce this. &amp;nbsp;Maybe it's just all our boxes, maybe it's a misconfiguration, maybe it's a framework issue that could just as easily be fixed.&lt;/p&gt;
&lt;p&gt;Anyways, thanks for your help.&lt;/p&gt;
&lt;p&gt; &amp;nbsp;John&lt;/p&gt;
</description></item><item><title>re: ASP.NET Memory Leak: Byte arrays rooted in System.Security.Policy.Evidence</title><link>http://blogs.msdn.com/tess/archive/2008/06/25/asp-net-memory-leak-byte-arrays-rooted-in-system-security-policy-evidence.aspx#8832042</link><pubDate>Mon, 04 Aug 2008 23:06:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8832042</guid><dc:creator>Tess</dc:creator><description>&lt;p&gt;interesting... I dot recognize the problem though, sorry&lt;/p&gt;
</description></item><item><title>re: ASP.NET Memory Leak: Byte arrays rooted in System.Security.Policy.Evidence</title><link>http://blogs.msdn.com/tess/archive/2008/06/25/asp-net-memory-leak-byte-arrays-rooted-in-system-security-policy-evidence.aspx#9412479</link><pubDate>Wed, 11 Feb 2009 13:43:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9412479</guid><dc:creator>Michael Schwarz</dc:creator><description>&lt;p&gt;Hi John, hi Tess,&lt;/p&gt;
&lt;p&gt;I have the same issue here that I can see the content of the DLLs in \bin in memory. Maybe Tess has some time to have a look on this problem.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;
</description></item><item><title>Best Practices for CRM Memory Usage</title><link>http://blogs.msdn.com/tess/archive/2008/06/25/asp-net-memory-leak-byte-arrays-rooted-in-system-security-policy-evidence.aspx#9473388</link><pubDate>Fri, 13 Mar 2009 19:54:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9473388</guid><dc:creator>Microsoft Dynamics CRM Team Blog</dc:creator><description>&lt;p&gt;Are you trying to improve the memory usage of your .net application? I’ve spent some time recently trying&lt;/p&gt;
</description></item></channel></rss>