<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.atalasoft.com/cs/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>Rick Minerich's Development Wonderland : C++, gc, F#, Tutorials, asp.net</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2B002B00_/gc/F_2300_/Tutorials/asp.net/default.aspx</link><description>Tags: C++, gc, F#, Tutorials, asp.net</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Changing Your Garbage Collector Settings on the Fly (.NET Memory Management: Part 5)</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx</link><pubDate>Wed, 20 Aug 2008 20:39:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:15313</guid><dc:creator>RickM</dc:creator><slash:comments>7</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/15313.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=15313</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=15313</wfw:comment><description>&lt;p&gt;It has come to my attention via a recent &lt;a href="http://dotnet.dzone.com/news/low-latency-gc-net-35"&gt;DZone article&lt;/a&gt; that .NET 3.5 and 2.0 SP1 jointly included a new feature which lets you manipulate the way your garbage collector acts programmatically.&amp;nbsp; This can be done through changing the value of a new property of the System.Runtime.GCSettings class named LatencyMode. In this article I will walk you through this new property and the different effects of each of it's possible settings.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Other Articles in This Series&lt;br&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/03/net-memory-managment-part-1-basic-housekeeping.aspx"&gt;Part 1 – Basic Housekeeping&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/15/improving-performance-through-stack-allocation-net-memory-management-part-2.aspx"&gt;Part 2 – Improving Performance Through Stack Allocation&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/04/22/increasing-the-size-of-your-stack-net-memory-management-part-3.aspx"&gt;Part 3 – Increasing the Size of your Stack&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/05/14/choosing-the-right-garbage-collector-settings-for-your-application-net-memory-management-part-4.aspx"&gt;Part 4 – Choosing the Right Garbage Collector Settings&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;Part 5 – Changing Your Garbage Collector Settings on the Fly&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;LatencyMode&lt;/b&gt; &lt;br&gt;&lt;/p&gt;&lt;p&gt;The new LatencyMode property accepts three different enumerated values.&amp;nbsp; The first two of which are Batch and Interactive which correspond to turning &amp;lt;gcConcurrent&amp;gt; on and off inside of your application configuration.&amp;nbsp; However, the effects of the third value, which is named LowLatency, were previously unavailable by any means.&amp;nbsp; By setting this the LatencyMode to LowLatency you can now put the Garbage Collector in an ultra-conservative mode which will insure the application will be interrupted as infrequently as possible.&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;p&gt;There are a couple of things you should take note of before changing your Garbage Collector's LatencyMode:&lt;br&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;LatencyMode settings are process-wide and so all of the threads in your application will be effected.&lt;/li&gt;&lt;li&gt;Changing LatencyMode will have no effect if your application has &amp;lt;gcServer&amp;gt; mode set in its configuration file.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Now, let’s explore each of the possible values of LatencyMode in detail:&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Batch &lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;When it’s useful: &amp;nbsp;&lt;br&gt;It’s useful in applications without a UI and in Server Based Software.&amp;nbsp; It may also be useful to switch your garbage collector into Batch latency mode if your application has a data crunching mode which occurs after a user interface.&lt;br&gt;&lt;/p&gt;&lt;p&gt;What it does: &lt;br&gt;This is the most intrusive setting.&amp;nbsp; Garbage Collection is done non-concurrently in one big batch call. Your program will be suspended while garbage collection takes place.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Defaults:&lt;br&gt;This is the default value when &amp;lt;gcConcurrent&amp;gt; is disabled.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Notes:&lt;br&gt;Even though this will be the enumeration which will be set if &amp;lt;gcServer&amp;gt; is enabled, the garbage collector will act as described in my &lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/05/14/choosing-the-right-garbage-collector-settings-for-your-application-net-memory-management-part-4.aspx"&gt;previous article&lt;/a&gt;.&amp;nbsp; In fact, if you have your application defined to be in &amp;lt;gcServer&amp;gt; mode the LatencyMode property cannot be changed from its default of “Batch”.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Interactive&lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;When it’s useful:&lt;br&gt;It’s the best mode for most any UI-based application. &lt;br&gt;&lt;/p&gt;&lt;p&gt;What it does:&lt;br&gt;This is the most balanced setting.&amp;nbsp; Garbage Collection happens concurrently with your application.&amp;nbsp; Most of the work is done in a separate thread and although your application will be suspended it will not happen very often and for only very short periods of time. &lt;br&gt;&lt;/p&gt;&lt;p&gt;Defaults:&lt;br&gt;This is the default value for garbage collection on workstations.&amp;nbsp; If &amp;lt;gcConcurrent&amp;gt; is left at its default value, this is the type of garbage collection that will occur.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;LowLatency&lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;When it’s useful:&lt;br&gt;It’s useful for time sensitive applications such as 3d rendering or data acquisition.&lt;br&gt;&lt;/p&gt;&lt;p&gt;What it does:&lt;br&gt;This is the least intrusive mode the Garbage Collector can be set to.&amp;nbsp; As in Interactive, garbage collections happen concurrently with your application.&amp;nbsp; However, collection of older objects will only happen when memory pressure becomes high.&amp;nbsp; Collection of generation 2 objects is kept to a bare minimum.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Defaults:&lt;br&gt;This is never the default setting.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Notes:&lt;br&gt;LowLatency mode was designed for short time use only during time-critical sections of your application.&amp;nbsp; Leaving an application in LowLatency mode for an extended period of time will cause unused objects accumulate.&amp;nbsp; Before using low latency mode, you should take a look at the guidelines laid out at the bottom of the &lt;a href="http://msdn.microsoft.com/en-us/library/bb384202.aspx"&gt;MSDN Latency Modes page&lt;/a&gt;. &lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;References&lt;/b&gt;&lt;br&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb384202.aspx"&gt;MSDN Visual Studio 2008 Developer Center – Latency Modes&lt;/a&gt;&lt;br&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.gclatencymode.aspx"&gt;MSDN .NET Framework Developer Center – GCLatencyMode Enumeration&lt;/a&gt;&lt;br&gt;&lt;a href="http://dotnet.dzone.com/news/low-latency-gc-net-35"&gt;DZone - Low-Latency GC in .NET 3.5&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;amp;;subject=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;amp;;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;amp;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;amp;;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx&amp;amp;;title=Changing+Your+Garbage+Collector+Settings+on+the+Fly+(.NET+Memory+Management%3a+Part+5)&amp;amp;;top=1" target="_blank" title = "Post http://www.atalasoft.com/cs/blogs/rickm/archive/2008/08/20/changing-your-garbage-collector-settings-on-the-fly-net-memory-management-part-5.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=15313" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/code/default.aspx">code</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/optimization/default.aspx">optimization</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2B002B00_/default.aspx">C++</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/VB.NET/default.aspx">VB.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Tutorials/default.aspx">Tutorials</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/memory/default.aspx">memory</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/garbage+collection/default.aspx">garbage collection</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/gc/default.aspx">gc</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category></item><item><title>Choosing the Right Garbage Collector Settings for Your Application (.NET Memory Management: Part 4)</title><link>http://www.atalasoft.com/cs/blogs/rickm/archive/2008/05/14/choosing-the-right-garbage-collector-settings-for-your-application-net-memory-management-part-4.aspx</link><pubDate>Wed, 14 May 2008 18:11:00 GMT</pubDate><guid isPermaLink="false">647108ca-f046-4d8d-9feb-a7fbd2049b37:14040</guid><dc:creator>RickM</dc:creator><slash:comments>5</slash:comments><comments>http://www.atalasoft.com/cs/blogs/rickm/comments/14040.aspx</comments><wfw:commentRss>http://www.atalasoft.com/cs/blogs/rickm/commentrss.aspx?PostID=14040</wfw:commentRss><wfw:comment>http://www.atalasoft.com/cs/blogs/rickm/rsscomments.aspx?PostID=14040</wfw:comment><description>Tuning the garbage collector to the specific context of the particular application can significantly improve the performance of both non-threaded and multi-threaded applications. In this post I discuss the gcConcurrent and gcServer settings which allow...(&lt;a href="http://www.atalasoft.com/cs/blogs/rickm/archive/2008/05/14/choosing-the-right-garbage-collector-settings-for-your-application-net-memory-management-part-4.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.atalasoft.com/cs/aggbug.aspx?PostID=14040" width="1" height="1"&gt;</description><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/F_2300_/default.aspx">F#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/code/default.aspx">code</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/optimization/default.aspx">optimization</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/.NET/default.aspx">.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/C_2B002B00_/default.aspx">C++</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/VB.NET/default.aspx">VB.NET</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/Tutorials/default.aspx">Tutorials</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/memory/default.aspx">memory</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/garbage+collection/default.aspx">garbage collection</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/gc/default.aspx">gc</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/asp.net/default.aspx">asp.net</category><category domain="http://www.atalasoft.com/cs/blogs/rickm/archive/tags/fsharp/default.aspx">fsharp</category></item></channel></rss>