lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Fwd: ThreadLocal in SegmentReader
Date Mon, 07 Jul 2008 21:09:56 GMT

ThreadLocal, which we use in several places in Lucene, causes a leak  
in app servers because the classloader never fully deallocates  
Lucene's classes because the ThreadLocal is holding strong references.

Yet, ThreadLocal is very convenient for avoiding synchronization.

Does anyone have any ideas on how to solve this w/o falling back to  
"normal" synchronization?

Mike

Begin forwarded message:

> From: "Yonik Seeley" <yonik@apache.org>
> Date: July 7, 2008 3:30:28 PM EDT
> To: java-user@lucene.apache.org
> Subject: Re: ThreadLocal in SegmentReader
> Reply-To: java-user@lucene.apache.org
>
> 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-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message