lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vova Tymchenko <>
Subject Re: Possible leaks in SegmentReader and TermInfosReader
Date Fri, 30 Mar 2007 16:30:10 GMT
This behavior is a bit strange in that SegmentReader keeps the file open (thus it cannot be
while the thread is alive. Also, you never know when GC is going to kick in, so the file will
not be
available for deletion until GC happens. Also, see the a couple of emails from the beginning
of the
March, another person has found this leak with the help of profiler.

Anyway, this change fixed my local problem so I thought to share it 8-)

----- Original Message ----
From: Joe Shaw <>
Sent: Thursday, March 29, 2007 8:20:15 PM
Subject: Re: Possible leaks in SegmentReader and TermInfosReader


On 3/29/07, Vova Tymchenko <> wrote:
> The trouble that I see with SegmentReader (and TermInfosReader as well) is that it stores
> 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:


Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.

View raw message