You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Patrick Diviacco <pa...@gmail.com> on 2011/04/04 13:22:39 UTC

how to delete a RAMDirectory from memory

Since I need to overwrite an old ramDirectory file and I don't want memory
leaks, I have the following code lines to close first the existing
RAMDirectory and create a new one.

INDEX_DIR.close();
INDEX_DIR = new RAMDirectory();

However, I get the following exception. Should I remove close() line and
just create a new RAMDirectory ? The old one will be deleted anyway ?

thans

Exception in thread "main" org.apache.lucene.store.AlreadyClosedException:
this Directory is closed
at org.apache.lucene.store.Directory.ensureOpen(Directory.java:224)
at org.apache.lucene.store.RAMDirectory.listAll(RAMDirectory.java:86)
at
org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:529)
at
org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:481)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:256)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:249)
at org.apache.lucene.index.IndexReader.indexExists(IndexReader.java:915)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:740)
at CollectionIndexer.run(CollectionIndexer.java:85)
at Clusterer.<init>(Clusterer.java:76)
at Main.main(Main.java:11)