title: Memory leak during repeated lucene query searches?
body: <p>Basically, I simply want to do many searches on a given lucene index.</p>
  
  <p>Therefore, I made a class Data with final 'analyzer', 'reader', 'searcher' and 'parser' fields, (all properly initialized in the constructor). The class also provides a 'search' method to search the index. This is all shown in the code below. </p>
  
  <p>The problem is however that memory gradually becomes filled after many calls to 'search' (with different queries). I did not check what happens when always the same query is used. I looked around already for possible answers, and it seems to be best practice to keep the searcher etc open across different searches, so I guess that is not the problem. Any other ideas?</p>
  
  <p>Thanks, Joachim.</p>
  
  <p>(example) code:</p>
  
  <pre><code>public class Data {
  
      private final Analyzer analyzer;
      private final IndexReader reader;
      private final IndexSearcher searcher;   
      private final QueryParser parser;
  
      public Data(String indexPath, Analyzer analyzer) throws IOException {
          this.analyzer = analyzer;
          Directory directory =  FSDirectory.open(indexPath);
          reader = new FilterIndexReader(IndexReader.open(directory, true));
                  directory.close();
          searcher = new IndexSearcher(reader);
          parser =  new QueryParser(Version.LUCENE_CURRENT, 
                                                 FieldName.CONTENT, analyzer);
      }    
  
      public TopDocs search(String line, Integer maxHits) throws ... { 
          Query query = parser.parse(QueryParser.escape(line));
          return searcher.search(query, maxHits);
      }
  }
  </code></pre>