lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Puchkovskiy <roman.puchkovs...@blandware.com>
Subject Re: ThreadLocal in SegmentReader
Date Sat, 12 Jul 2008 04:38:07 GMT

Well, this 'replacement' of the ThreadLocal does not solve the initial
problem. As there's always at least one ThreadLocal which binds the object
loaded by the web-app to the Thread which is _not_ loaded by the web-app,
the classloader never may be unloaded.

You are right, this is not the 'leak' in the usual sense, but this is not
the 'delayed GC' problem, this is the 'never-happening-GC' problem when you
have the classloader which needs to be unloaded.


Michael McCandless-2 wrote:
> 
> 
> After discussing this on java-dev:
> 
>     
> http://mail-archives.apache.org/mod_mbox/lucene-java-dev/200807.mbox/%3CF5FC94B2-E5C7-40C0-8B73-E12245B91CEE@mikemccandless.com%3E
> 
> it seems that this is not in fact a leak but rather a delayed GC  
> issue.  The objects are eventually freed, on Sun 1.4, 1.5 and 1.6.
> 
> When a ThreadLocal instance becomes unreferenced & GC'd, Java does not  
> immediately reclaim the now-unreferenced objects, if the thread  
> remains alive.  However, over time, as other ThreadLocals are used  
> with that thread, those stale objects do eventually get reclaimed.  So  
> my feeling for now is it's OK for Lucene to continue to use non-static  
> ThreadLocals.
> 
> Mike
> 
> Yonik Seeley wrote:
> 
>> On Mon, Jul 7, 2008 at 2:43 PM, Michael McCandless
>> <lucene@mikemccandless.com> wrote:
>>> So now I'm confused: the SegmentReader itself should no longer be  
>>> reachable,
>>> assuming you are not holding any references to your IndexReader.
>>>
>>> Which means the ThreadLocal instance should no longer be reachable.
>>
>> It will still be referenced from the Thread(s) ThreadLocalMap
>> The key (the ThreadLocal) will be weakly referenced, but the values
>> (now stale) are strongly referenced and won't be actually removed
>> until the table is resized (under the Java6 impl at least).
>> Nice huh?
>>
>> -Yonik
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ThreadLocal-in-SegmentReader-tp18306230p18416048.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message