That is a bad idea in general, since threads usually don't die.
If we take a traditional ASP.Net application, the threads are on the thread
pool, and are mostly busy serving requests, they don't tend to die that
often.

On 3/29/07, Joe Shaw <[EMAIL PROTECTED]> wrote:

Hi,

On 3/29/07, Vova Tymchenko <[EMAIL PROTECTED]> wrote:
> The trouble that I see with SegmentReader (and TermInfosReader as well)
is that it stores references
> to TermVectorsReader in ThreadLocalStore when GetTermVectorsReader is
called, but .Close method fails
> to close and clean up that reference.

I believe the idea here (at least for TermInfosReader) is to cache
that object so that multiple searches on the same thread do not have
to continuously reopen the term info file, which can be a pretty big
performance hit.  Removing the reference in DoClose() will effectively
undo this optimization.

I think that the references to the data stored in the ThreadLocalStore
will be GCable once the thread containing it dies.

There was a recent thread about this on the java-dev list, in which
someone thought that ThreadLocals were causing a leak, but it turned
out to be a bug in the user's code:


http://www.archivum.info/[email protected]/2006-12/msg00273.html

Joe

Reply via email to