lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: File Handle Leaks During Lucene 3.0.2 Merge
Date Thu, 30 Sep 2010 21:52:38 GMT
You can also use the IndexReader's incRef/decRef methods.


On Thu, Sep 30, 2010 at 6:12 AM, Uwe Schindler <> wrote:
> Hi Jamie,
>>  >It's good to cache the reader, but, finalize would worry me too since
>> have no control over when GC gets around to calling it... you risk  >tying
> up
>> resources for longer than necessary.
>> I did it this way, as I didn't want to over complicate the code by
> introducing
>> mechanisms to track the number of search threads using a shared
> indexreader.
>> Admittedly, its not a very clean solution but in my case it does work. Is
> there a
>> particular technique for knowing when to a close a reader when there are
>> multiple search threads using that reader?
>> Should I keep some kind of counter and override the close method of the
>> reader such that the underlying reader is only closed when everyone's done
>> with it?
> The easiest would be an AtomicInteger for each cached reader that gets
> incremented before you start a search and decremented on finishing search.
> You can safely close the reader, when the integer is 0.
> Uwe
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message