<?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 Debugging : Threading</title><link>http://blogs.msdn.com/tom/archive/tags/Threading/default.aspx</link><description>Tags: Threading</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>J# threads calling GC.Collect</title><link>http://blogs.msdn.com/tom/archive/2008/01/21/j-threads-calling-gc-collect.aspx</link><pubDate>Mon, 21 Jan 2008 22:53:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7187545</guid><dc:creator>Tom</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/tom/comments/7187545.aspx</comments><wfw:commentRss>http://blogs.msdn.com/tom/commentrss.aspx?PostID=7187545</wfw:commentRss><wfw:comment>http://blogs.msdn.com/tom/rsscomments.aspx?PostID=7187545</wfw:comment><description>&lt;h3&gt;Problem&lt;/h3&gt;  &lt;p&gt;We have had a few customers run into this issue where they are using the J# ThreadEnd objects and see problems with the GC running a lot.&amp;#160; If you look at the actual callstack that is calling the GC, it will be the finalizer thread cleaning up this ThreadEnd as we see here:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre class="debug"&gt;0:036&amp;gt; k
Child-SP RetAddr           Call Site
05cef478 00000000`1bf31dc5 mscorwks!GCInterface::CollectGeneration
05cef480 00000642`7f66bdc6 vjslib_ni!com.ms.vjsharp.lang.ThreadEnd.Finalize()+0x35
05cef4e0 00000642`7f4ebf2b mscorwks!FastCallFinalizeWorker+0x6 
05cef510 00000642`7f4ec075 mscorwks!FastCallFinalize+0xbb 
05cef590 00000642`7f4f16e2 mscorwks!MethodTable::CallFinalizer+0x69 
05cef5e0 00000642`7f4f1524 mscorwks!SVR::CallFinalizer+0x72 
05cef640 00000642`7f4f146b mscorwks!SVR::DoOneFinalization+0x84 
05cef700 00000642`7f61fb1b mscorwks!SVR::FinalizeAllObjects+0x9b
05cef7c0 00000642`7f5264cc mscorwks!SVR::FinalizeAllObjects_Wrapper+0x1b
05cef7f0 00000642`7f52693d mscorwks!ManagedThreadBase_DispatchMiddle+0x12c 
05cef900 00000642`7f608455 mscorwks!ManagedThreadBase_DispatchOuter+0x31 
05cef940 00000642`7f4a71bc mscorwks!ManagedThreadBase_DispatchInCorrectAD+0x15
05cef970 00000642`7f44b939 mscorwks!Thread::DoADCallBack+0xd0
05cefab0 00000642`7f4f15f6 mscorwks!ManagedThreadBase_DispatchInner+0x51 
05cefb00 00000642`7f4f146b mscorwks!SVR::DoOneFinalization+0x156 
05cefbc0 00000642`7f4b679d mscorwks!SVR::FinalizeAllObjects+0x9b 
05cefc80 00000642`7f5264cc mscorwks!SVR::GCHeap::FinalizerThreadWorker+0xbd
05cefcc0 00000642`7f52693d mscorwks!ManagedThreadBase_DispatchMiddle+0x12c
05cefdd0 00000642`7f463c36 mscorwks!ManagedThreadBase_DispatchOuter+0x31
05cefe10 00000642`7f4b6d64 mscorwks!ManagedThreadBase_NoADTransition+0x42&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;From this we can see that the Finalize method of ThreadEnd is calling the collection.&amp;#160; This is something that these threads do.&lt;/p&gt;

&lt;h3&gt;Workaround&lt;/h3&gt;

&lt;p&gt;The only way around this, if this is causing a problem, is to switch from using Java threads to .NET Threads instead as they don't call GC.Collect().&lt;/p&gt;

&lt;p&gt;This problem has been mentioned a few times, including on &lt;a href="http://blogs.msdn.com/maoni/archive/2004/06/03/148029.aspx"&gt;Maoni's blog&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7187545" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/tom/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/tom/archive/tags/Threading/default.aspx">Threading</category></item></channel></rss>