On Mon, Sep 2, 2013 at 4:10 PM, Ankit Murarka <ankit.mura...@rancoretech.com> wrote: > There's a reason why Writer is being opened everytime inside a while loop. I > usually open writer in main method itself as suggested by you and pass a > reference to it. However what I have observed is that if my file contains > more than 4 lakh lines, the writer.add(doc) line does not execute and throws > an OutOfMemoryError although JVM is provided with enough heap.
The problem isn't opening it multiple times (although that does seem unnecessary too), the problem is that half the time you're not closing it. Try refactoring to always use the try(){} syntax so that all your Closeable objects are being closed properly. You'll find all sorts of issues with the code you posted. TX --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org