lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: Memory leak with Lucene Search ?
Date Tue, 12 Jul 2011 11:24:08 GMT
Lucene does not cache results.  Operating systems do cache things and
on unix anyway (no idea about windows) some speedups over time can
reasonably be attributed to disk caching by the OS.

Have you profiled your app to find out exactly what is using the
memory? Do you just use the one searcher or are you opening new ones
from time to time?  If the latter, are you closing the old ones?


On Tue, Jul 12, 2011 at 11:52 AM, dangabhay <> wrote:
> Hi all,
> We are using Lucene 2.9.0 to power a search and are performing a large
> number of searches. We are initializing our searcher with the code:
> Directory directory = File(Constants.IndexLocation));
> Searcher searcher = new IndexSearcher(directory,true);
> Upon every search request, we are performing the following
> TopDocs results =,Constants.MAXHITS);
> As expected, the first request takes up a large amount of time as the index
> warms up. However, we have noticed that the time taken keeps decreasing
> continuously as and when more results are served. My guess is that results
> are being cached somewhere.
> The runtime classes for directory and index reader are as follows:
> org.apache.lucene.index.ReadOnlyDirectoryReader
> Eventually, JVM runs out of memory as we see from jvm stats that old
> generation capacity reaches the maximum. We are using Concurrent Mark sweep
> GC strategy, and it gets invoked during every search request thereafter.
> I have tried looking for answers in forums, but couldn't find any. As per
> many threads, there is no caching involved in Lucene by default, unless
> QueryFilter and CachingWrapperFilter are used. I tried looking into Lucene
> code also a bit, but couldn't find any clues.
> Does anyone have any pointers as to why this could be happening ?
> Thanks!
> Abhay
> --
> View this message in context:
> Sent from the Lucene - Java Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message