<?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>Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx</link><description>LOH (Large Object Heap) contains objects that are 85,000 bytes or bigger (there’s also some objects that are less than 85,000 bytes that are allocated on the LOH by the runtime itself but usually they are very small and we’ll ignore them for this discussion).</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Interesting Finds</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#579132</link><pubDate>Wed, 19 Apr 2006 20:00:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:579132</guid><dc:creator>Jason Haley</dc:creator><description /></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#579183</link><pubDate>Wed, 19 Apr 2006 21:04:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:579183</guid><dc:creator>Anonymous</dc:creator><description>&amp;gt; the other reason is people usually don’t churn LOH too &lt;br&gt;&amp;gt; much – one typical pattern I’ve seen people use LOH is &lt;br&gt;&amp;gt; to allocate some large arrays that hold on to small &lt;br&gt;&amp;gt; objects. &lt;br&gt;&lt;br&gt;What about DataTables? Large DataTable's allocates big continuous arrays for column values and there is no way to reuse one column array for another table, after disposing the first one. &amp;nbsp;&lt;br&gt;&lt;br&gt;Column of GUIDs or decimals can be allocated in LOH when DataTable contains about 5000 rows - not very much.</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#579286</link><pubDate>Wed, 19 Apr 2006 22:53:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:579286</guid><dc:creator>TAG</dc:creator><description>I've question - how 85000 was selected ? Any reasoning ?</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#581021</link><pubDate>Sat, 22 Apr 2006 01:12:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:581021</guid><dc:creator>maoni</dc:creator><description>Unfortunately I can't answer about DataTables - it's outside of my expertise. &lt;br&gt;&lt;br&gt;85,000 bytes was selected based on tuning (running a bunch of scenarios of our own and from our partner teams).</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#590106</link><pubDate>Thu, 04 May 2006 21:41:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:590106</guid><dc:creator>Nomad</dc:creator><description>Maoni, It would be great if you look at my problem.. I've read all of your articles and it looks like that my trouble lies somewhere in memory defragmentation or something similar.&lt;br&gt;Look at url that I provided or contact me at gorbuz@gmail.com&lt;br&gt;PS. Sorry for my poor English, I'm from Ukraine</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#594920</link><pubDate>Thu, 11 May 2006 02:02:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:594920</guid><dc:creator>maoni</dc:creator><description>Nomad, I looked the link but I am not sure exactly how your issue is related to GC based on the info given. You didn't say if you were using workstation GC (with or without concurrent GC) or server GC. It should be easy to determine if the thread is a GC thread if you know what flavor you are using and by looking at the callstacks from those threads. &amp;nbsp;There's no GC threads that are specifically for &amp;quot;memory defragmentation&amp;quot;.</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#595298</link><pubDate>Thu, 11 May 2006 15:45:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595298</guid><dc:creator>Nomad</dc:creator><description>Greetings. Thanks for response.&lt;br&gt;I'm using workstation GC now, but short test on server GC does not lead to that uncommon behaivor but just raised memory usage twice and up to OOM's. I'll test it again after RAM upgrade.&lt;br&gt;I've tried to collect stack traces using SysInternals Process Explorer (with windows debugging symbols, of course), but it looks like execution point for that thread changes every second and all of traces are just too different. Maybe we should use some other tools to get it?&lt;br&gt;I've found another strange thing - when I moved byte buffer operations (allocations, freeing, byte queue) to separate C++ assembly and done explicit memory allocation via Marshal::AllocHGlobal/ Marshal::FreeHGlobal (slower case) and c++ new/delete statements, server normal uptime (work time before &amp;quot;phantom thread&amp;quot; spawns) raised to 5-6hours, from 1-2 hours.&lt;br&gt;&lt;br&gt;Just to explain why I've moved to explicit allocations I'll give you an example: there were 13649552 buffers allocated and 13648731 buffers released during 1h46m worktime. Each buffer is just a byte[] array of some size (less than 10k).&lt;br&gt;I asked myself, is that a normal workload for workstation GC? May be it just get flooded with such numbers? But perf. counters show only about 5-8% time in GC.. I've tried and got such result.. </description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#595821</link><pubDate>Fri, 12 May 2006 06:44:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595821</guid><dc:creator>maoni</dc:creator><description>Nomad, try tuning concurrent GC off (look at my Using GC efficiently - part 2) - that way you can be sure there's no threads from GC (GC would be performed on your thread that triggered a GC). </description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#595859</link><pubDate>Fri, 12 May 2006 08:26:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595859</guid><dc:creator>Nomad</dc:creator><description>Ok, I set it up. I'll tell you of any results this evening (or morning in your time zone :))</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#596872</link><pubDate>Sat, 13 May 2006 14:35:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:596872</guid><dc:creator>Nomad</dc:creator><description>Behaivor with concurrent GC turned off changed significantly. First of all, server performance increased greatly - CPU usage shrinked in 1.5 times. For a few hours it worked perfectly, but after some time something strange happening - Gen 2 Heap raised to 450 MB, number of Gen 2 collections is increasing every second, % of time in GC is sliding between 5 and 80 percents.&lt;br&gt;When I read your &amp;quot;Using GC efficiently&amp;quot; just about a year ago, I began to tune my app's memory usage and always looked at performance monitor - I never had such high Gen 2 heap and collections and % time in GC always was &amp;lt;= 10%. It looks like there is hidden error (or a lot of errors) in my code that was not detected correctly with concurrent GC (except of strange thread).. I see, it's time to read your articles again and again :)&lt;br&gt;</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#659167</link><pubDate>Fri, 07 Jul 2006 19:35:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:659167</guid><dc:creator>samfung2000</dc:creator><description>GC collects base on 3 condictions:&lt;br&gt;1) &amp;nbsp; &amp;nbsp; &amp;nbsp;Allocation exceeds the Gen0 threshold;&lt;br&gt;&lt;br&gt;2) &amp;nbsp; &amp;nbsp; &amp;nbsp;System.GC.Collect is called;&lt;br&gt;&lt;br&gt;3) &amp;nbsp; &amp;nbsp; &amp;nbsp;System is in low memory situation;&lt;br&gt;&lt;br&gt;Can you please elaborate 1, What is the Gen0 threshold?&lt;br&gt;I thought when small object heap runs low GC would just allocate another Segment.&lt;br&gt;&lt;br&gt;How responsive is 3? &lt;br&gt;My app has high memory usage in a single call and seems like GC is not collecting quick enough and therefore got an OufOfMemory exception.&lt;br&gt;&lt;br&gt;Thanks.&lt;br&gt;PS this is good stuff.&lt;br&gt;</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#673181</link><pubDate>Fri, 21 Jul 2006 00:51:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:673181</guid><dc:creator>maoni</dc:creator><description>samfung2000, if you search for either &amp;quot;budget&amp;quot; or &amp;quot;threshold&amp;quot; in my blog you will see explanation of it.&lt;br&gt;&lt;br&gt;Re your question about your application getting OOM, you should verify that the objects are indeed dead. If you are sure of that please do feel free to contact our product support.</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#1938000</link><pubDate>Fri, 23 Mar 2007 18:38:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1938000</guid><dc:creator>Ulf</dc:creator><description>&lt;p&gt;Almost a year after the last :-)&lt;/p&gt;
&lt;p&gt;One thing I am confused about is why double-objects are handled differently than other scalar types.&lt;/p&gt;
&lt;p&gt;The limit for a double-array seems to be 8K instead of 85K (which has a very bad implication of the application I am working on).&lt;/p&gt;
&lt;p&gt;This can be controlled by running this simple code:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;static void Main(string[] args)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;double[] array1 = new double[999];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(GC.GetGeneration(array1));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;double[] array2 = new double[1000];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(GC.GetGeneration(array2));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;The printout is:&lt;/p&gt;
&lt;p&gt;0&lt;/p&gt;
&lt;p&gt;2&lt;/p&gt;
&lt;p&gt;I.e. the double-array with 1000 elements (8K) is immediately allocated to generation 2,in this case LOH.&lt;/p&gt;
&lt;p&gt;To me this feels like a serous bug but are there anything smart here?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Ulf&lt;/p&gt;
</description></item><item><title>LOH and doubles</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#2013279</link><pubDate>Mon, 02 Apr 2007 21:14:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2013279</guid><dc:creator>OmegaMan</dc:creator><description>&lt;p&gt;I reported this to Microsoft Connect and it now being considered a bug on the doubles issue. &lt;/p&gt;
&lt;p&gt;See:&lt;/p&gt;
&lt;p&gt;Large Object Heap (LOH) does not behave as expected for Double array placement &lt;/p&gt;
&lt;p&gt;Link:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266330"&gt;https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=266330&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#2649339</link><pubDate>Tue, 15 May 2007 16:28:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2649339</guid><dc:creator>maoni</dc:creator><description>&lt;p&gt;It's not a bug - we do this for performance reasons because doubles are accessed faster when they are aligned on a 8-byte boundary which large objects are.&lt;/p&gt;
</description></item><item><title>Scalable Memory Usage in SQLCLR</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#3028227</link><pubDate>Fri, 01 Jun 2007 20:56:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3028227</guid><dc:creator>SQLCLR Performance</dc:creator><description>&lt;p&gt;There are few constraints on memory usage in SQLCLR modules. This freedom is one of the benefits of the&lt;/p&gt;
</description></item><item><title>Why does the clone for double array of length 124 go to LOH</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#8334738</link><pubDate>Tue, 25 Mar 2008 04:54:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8334738</guid><dc:creator>alps_xing</dc:creator><description>&lt;p&gt;Hi, Maoni&lt;/p&gt;
&lt;p&gt; &amp;nbsp;I used below codes to do a LOH test, and found that when the double array length is larger-equal than 124, the clone operation will increase the LOH usage. However as we know, the LOH threshold for double array should be 999.&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Does the clone operation do some boundary alignment? And why the threshold for Clone is 123?&lt;/p&gt;
&lt;p&gt; &amp;nbsp;As below, the length of the array is 124. The array1's generation is 0, and array2's generation is 2, which make the LOH churned.&lt;/p&gt;
&lt;p&gt; &amp;nbsp;If I change the array length to 123, the generation of array1 and array2 are both 0.&lt;/p&gt;
&lt;p&gt;using System;&lt;/p&gt;
&lt;p&gt;using System.Collections.Generic;&lt;/p&gt;
&lt;p&gt;using System.Text;&lt;/p&gt;
&lt;p&gt;namespace ConsoleApplication2&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;class Program&lt;/p&gt;
&lt;p&gt; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;static void Main(string[] args)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;while(true)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// If I change the size to 123, the LOH will not be churned.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;double[] array1 = new double[124];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(GC.GetGeneration(array1));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;double[] array2 = (double [])array1.Clone();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.Threading.Thread.Sleep(1);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Xing Qianqian&lt;/p&gt;
&lt;p&gt;25-Mar-2008&lt;/p&gt;
</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#8473916</link><pubDate>Thu, 08 May 2008 22:31:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8473916</guid><dc:creator>Jairo</dc:creator><description>&lt;p&gt;What about the Cache? if I have a LOH in the Cache (maybe a DataSet), setting the Cache object to null is not allowed (an exception is thrown), just removing it would work?? (Cache.Remove(&amp;quot;objectId&amp;quot;)).&lt;/p&gt;
&lt;p&gt;Thanks!!!&lt;/p&gt;
</description></item><item><title>re: Large Object Heap</title><link>http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx#9902740</link><pubDate>Sat, 03 Oct 2009 15:29:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9902740</guid><dc:creator>Shane</dc:creator><description>&lt;p&gt;It would be nice if a lot of the .ToArray() function's could use recycled object's.&lt;/p&gt;
</description></item></channel></rss>