lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <>
Subject [jira] Created: (LUCENE-1383) Workaround ThreadLocal's "leak"
Date Thu, 11 Sep 2008 20:51:44 GMT
Workaround ThreadLocal's "leak"

                 Key: LUCENE-1383
             Project: Lucene - Java
          Issue Type: Bug
          Components: Index
    Affects Versions: 2.3.2, 2.3.1, 2.3, 2.2, 2.1, 2.0.0, 1.9
            Reporter: Michael McCandless
            Assignee: Michael McCandless
             Fix For: 2.4

Java's ThreadLocal is dangerous to use because it is able to take a
surprisingly very long time to release references to the values you
store in it.  Even when a ThreadLocal instance itself is GC'd, hard
references to the values you had stored in it are easily kept for
quite some time later.

While this is not technically a "memory leak", because eventually
(when the underlying Map that stores the values cleans up its "stale"
references) the hard reference will be cleared, and GC can proceed,
its end behavior is not different from a memory leak in that under the
right situation you can easily tie up far more memory than you'd
expect, and then hit unexpected OOM error despite allocating an
extremely large heap to your JVM.

Lucene users have hit this many times.  Here's the most recent thread:

And here's another:

And then there's LUCENE-436 and LUCENE-529 at least.

A google search for "ThreadLocal leak" yields many compelling hits.

Sun does this for performance reasons, but I think it's a terrible
trap and we should work around it with Lucene.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

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

View raw message