<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: ThreadLocal in One Click</title>
	<atom:link href="http://blogs.jetbrains.com/idea/2009/10/threadlocal-in-one-click/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.jetbrains.com/idea/2009/10/threadlocal-in-one-click/</link>
	<description>tips &#38; tricks, news, how-to's</description>
	<pubDate>Mon, 13 Feb 2012 08:06:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Niels Harremoes</title>
		<link>http://blogs.jetbrains.com/idea/2009/10/threadlocal-in-one-click/#comment-173195</link>
		<dc:creator>Niels Harremoes</dc:creator>
		<pubDate>Sat, 19 Mar 2011 16:12:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=2230#comment-173195</guid>
		<description>Sorry to revive an old thread, but I just stumbled upon this. I think this is a very dangerous quickfix, since it introduces a memory leak in an app server environment, where you want your classloaders to be unloadable?

Threadlocals are implemented as per-thread weak hashmaps. If the value contains a reference to the key, the values will never die, before the thread dies.

The value in this case is a SAXBuilder instance. This, of course has a reference to the SAXBuilder.class, which has a reference to the classloader for jdom, which has a reference to the JDOMUtil class, which has a reference to the static field, i.e. the ThreadLocal instace. So the loop is tied, and your jdom classloader can now never be garbage collected :-(

So IF the initial value in any way references the classloader which loaded the containing class, that classloader will be uncollectable.
This may or may not be a problem, depending on the use case. But I think it is a bit too dangerous to have as a quickfix?</description>
		<content:encoded><![CDATA[<p>Sorry to revive an old thread, but I just stumbled upon this. I think this is a very dangerous quickfix, since it introduces a memory leak in an app server environment, where you want your classloaders to be unloadable?</p>
<p>Threadlocals are implemented as per-thread weak hashmaps. If the value contains a reference to the key, the values will never die, before the thread dies.</p>
<p>The value in this case is a SAXBuilder instance. This, of course has a reference to the SAXBuilder.class, which has a reference to the classloader for jdom, which has a reference to the JDOMUtil class, which has a reference to the static field, i.e. the ThreadLocal instace. So the loop is tied, and your jdom classloader can now never be garbage collected <img src='http://blogs.jetbrains.com/idea/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>So IF the initial value in any way references the classloader which loaded the containing class, that classloader will be uncollectable.<br />
This may or may not be a problem, depending on the use case. But I think it is a bit too dangerous to have as a quickfix?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Markus Jevring</title>
		<link>http://blogs.jetbrains.com/idea/2009/10/threadlocal-in-one-click/#comment-127409</link>
		<dc:creator>Markus Jevring</dc:creator>
		<pubDate>Mon, 01 Mar 2010 13:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=2230#comment-127409</guid>
		<description>Unfortunately, this wonderful little trick doesn't work in the Community Edition =(</description>
		<content:encoded><![CDATA[<p>Unfortunately, this wonderful little trick doesn&#8217;t work in the Community Edition =(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anjan bacchu</title>
		<link>http://blogs.jetbrains.com/idea/2009/10/threadlocal-in-one-click/#comment-118709</link>
		<dc:creator>anjan bacchu</dc:creator>
		<pubDate>Fri, 30 Oct 2009 13:29:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=2230#comment-118709</guid>
		<description>hi there,

  cool!

  how long before eclipse copies it ? (as it's been doing for the last 8 years :-) )

BR,
~A</description>
		<content:encoded><![CDATA[<p>hi there,</p>
<p>  cool!</p>
<p>  how long before eclipse copies it ? (as it&#8217;s been doing for the last 8 years <img src='http://blogs.jetbrains.com/idea/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p>BR,<br />
~A</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felipe Cypriano</title>
		<link>http://blogs.jetbrains.com/idea/2009/10/threadlocal-in-one-click/#comment-118703</link>
		<dc:creator>Felipe Cypriano</dc:creator>
		<pubDate>Fri, 30 Oct 2009 11:52:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.jetbrains.com/idea/?p=2230#comment-118703</guid>
		<description>These "little" details makes idea the best IDE</description>
		<content:encoded><![CDATA[<p>These &#8220;little&#8221; details makes idea the best IDE</p>
]]></content:encoded>
	</item>
</channel>
</rss>

