lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trejkaz <>
Subject Is there a way to share IndexReader data sensibly across independent callers?
Date Fri, 05 Feb 2016 01:48:24 GMT
Hi all.

Suppose 100 independent callers are opening the same index like this:

    try (Directory directory =;
         IndexReader reader =
        // keeps reader open for a long time

Someone complains that we're using a lot of memory, because each
IndexReader has its own cache.
We don't have any context that would tell us about other threads in
the same JVM that might have opened the same reader, other than it
ultimately going through our own code in both cases.

Is there a proper way to share the underlying IndexReader data? I
don't particularly care whether it's the same IndexReader but maybe it
would help if it's at least the same SegmentReaders...

Our existing attempts to use ReaderManager are not really working
because there are issues with figuring out when it's okay to close a
Directory. It seems like the answer is "never", because the caller who
passes in the first one might still be using it. But if you never
close it (which does seem to be the right way), Windows ruins your
plans by refusing to let you delete the files.


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

View raw message