lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert engels <>
Subject Re: ThreadLocal leak (was Re: Leaking org.apache.lucene.index.* objects)
Date Tue, 19 Dec 2006 20:37:23 GMT
I would suggest that in order to even bring up "thread local issues"  
in the future that the submitter supplies a pure Java NON-LUCENE test  
case that demonstrates the problem (just as you would if reporting a  
bug to Sun).

All of the "guessing" about what is going on is counter productive.  
You can review the JDK source code, and you can run test cases.

There is nothing inherently broken in ThreadLocals, and people that  
keep claiming that are only doing a disservice to the people that  
make sure Java is a robust and reliable platform.

On Dec 19, 2006, at 1:41 PM, Yonik Seeley wrote:

> On 12/19/06, Otis Gospodnetic <> wrote:
>> I _think_ Robert is right and ThreadLocals are not the problem (I  
>> tried getting rid of them, and replacing them with an instance var  
>> last week, but run into problems with multi-threaded unit tests).
> If you want to try getting rid of the ThreadLocals, you can't replace
> with instance vars because the stuff put into the Threadlocals isn't
> thread safe.
> Replace the ThreadLocal stuff with the code that populated it in the
> first place.
> So for instance, in TermInfosReader, replace this
>  private SegmentTermEnum getEnum() {
>    SegmentTermEnum termEnum = (SegmentTermEnum)enumerators.get();
>    if (termEnum == null) {
>      termEnum = terms();
>      enumerators.set(termEnum);
>    }
>    return termEnum;
>  }
> With this:
>  private SegmentTermEnum getEnum() {
>     return terms()
>  }
>> What I'm seeing while profiling (and in production) is the  
>> accumulation of these:
>> This is related to  
>> (the commit for that patch also happens to coincide with when I  
>> started seeing the leak).
> I'll take a look into that.  Solr hasn't sync'd to that version of
> Lucene yet, so we haven't seen this problem of course :-)
> -Yonik
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message