Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-3409

NRT reader/writer over RAMDirectory memory leak

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.2, 3.3, 4.0-ALPHA
    • 3.4, 4.0-ALPHA
    • core/index
    • None
    • New

    Description

      with NRT reader/writer, emptying an index using:
      writer.deleteAll()
      writer.commit()
      doesn't release all allocated memory.

      for example the following code will generate a memory leak:

      /**

      • Reveals a memory leak in NRT reader/writer<br>
      • The following main() does 10K cycles of:
      • <ul>
      • <li>Add 10K empty documents to index writer</li>
      • <li>commit()</li>
      • <li>open NRT reader over the writer, and immediately close it</li>
      • <li>delete all documents from the writer</li>
      • <li>commit changes to the writer</li>
      • </ul>
      • Running with -Xmx256M results in an OOME after ~2600 cycles
        */
        public static void main(String[] args) throws Exception {
        RAMDirectory d = new RAMDirectory();
        IndexWriter w = new IndexWriter(d, new IndexWriterConfig(Version.LUCENE_33, new KeywordAnalyzer()));
        Document doc = new Document();

      for(int i = 0; i < 10000; i++) {
      for(int j = 0; j < 10000; ++j)

      { w.addDocument(doc); }

      w.commit();
      IndexReader.open(w, true).close();

      w.deleteAll();
      w.commit();
      }

      w.close();
      d.close();
      }

      Attachments

        Activity

          People

            mikemccand Michael McCandless
            talsteier tal steier
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: