lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <>
Subject Re: ThreadLocal leak (was Re: Leaking org.apache.lucene.index.* objects)
Date Tue, 19 Dec 2006 19:41:26 GMT
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();
    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 :-)


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

View raw message