<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://aspadvice.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>C# Nuggets : gc</title><link>http://aspadvice.com/blogs/rbirkby/archive/tags/gc/default.aspx</link><description>Tags: gc</description><dc:language>en</dc:language><generator>CommunityServer 2.1 (Build: 60809.935)</generator><item><title>The CLR garbage collector is in need of help</title><link>http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx</link><pubDate>Thu, 12 Jun 2008 10:54:00 GMT</pubDate><guid isPermaLink="false">e709ad4c-0c15-48eb-915e-c462c6e85445:43092</guid><dc:creator>rbirkby</dc:creator><slash:comments>0</slash:comments><comments>http://aspadvice.com/blogs/rbirkby/comments/43092.aspx</comments><wfw:commentRss>http://aspadvice.com/blogs/rbirkby/commentrss.aspx?PostID=43092</wfw:commentRss><description>&lt;p&gt;Back in 2000 when the CLR was first shown it&amp;#39;s generational garbage collector was fairly cutting edge. But it&amp;#39;s weaknesses show it&amp;#39;s age - and it desperately needs updating. &lt;/p&gt;&lt;p&gt;Here&amp;#39;s an example of just one of the ways the current GC (.Net 3.5) doesn&amp;#39;t work:&lt;/p&gt;&lt;p&gt;A .Net process with a number of threads has just saved a large amount of data to a database. All of these threads could potentially allocate memory which causes a GC collection. However, saving the data to the database is a fairly long operation and thus the data &lt;a href="http://blogs.msdn.com/ricom/archive/2003/12/04/41281.aspx"&gt;gets promoted&lt;/a&gt; into the GC&amp;#39;s generation 2. &lt;/p&gt;&lt;p&gt;After saving the data, the .Net process waits until it&amp;#39;s instructed to do some more work. However, because a large amount of data has been promoted into Gen2, it just sits there until sufficient new allocations cause a Gen2 GC collection. The problem is that if no new work happens for a long time (hours), these unreachable objects take up (virtual) address space. Yes, NT will swap it out to disk as virtual memory. But it&amp;#39;s still there.&lt;/p&gt;&lt;p&gt;The GC really needs a timer, which periodically checks if no GCs have happened recently and the process has consumed very little CPU, then perform a Gen2 collection. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Aside: Does anyone know how to trigger a GC.Collect() on a process from a different process, or from inside WinDbg? One of the problems with WinDbg/SOS is figuring out just which objects are reachable - you would have to !gcroot every possible object just to figure out which are the reachable ones.&lt;br /&gt;&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://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx&amp;amp;;subject=The+CLR+garbage+collector+is+in+need+of+help" target="_blank" title = "Post http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx&amp;amp;;title=The+CLR+garbage+collector+is+in+need+of+help" target="_blank" title = "Post http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx&amp;amp;title=The+CLR+garbage+collector+is+in+need+of+help" target="_blank" title = "Post http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx&amp;amp;;title=The+CLR+garbage+collector+is+in+need+of+help" target="_blank" title = "Post http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.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://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx&amp;amp;;title=The+CLR+garbage+collector+is+in+need+of+help&amp;amp;;top=1" target="_blank" title = "Post http://aspadvice.com/blogs/rbirkby/archive/2008/06/12/The-CLR-garbage-collector-is-in-need-of-help.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://aspadvice.com/aggbug.aspx?PostID=43092" width="1" height="1"&gt;</description><category domain="http://aspadvice.com/blogs/rbirkby/archive/tags/dotnet/default.aspx">dotnet</category><category domain="http://aspadvice.com/blogs/rbirkby/archive/tags/memory/default.aspx">memory</category><category domain="http://aspadvice.com/blogs/rbirkby/archive/tags/gc/default.aspx">gc</category></item></channel></rss>