lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Indexing large files?
Date Mon, 31 Aug 2009 14:28:16 GMT


I'm working with Lucene 2.4.0 and the JVM (JDK 1.6.0_07).  I'm
consistently receiving "OutOfMemoryError: Java heap space", when trying
to index large text files.


Example 1: Indexing a 5 MB text file runs out of memory with a 16 MB
max. heap size.  So I increased the max. heap size to 512 MB.  This
worked for the 5 MB text file, but Lucene still used 84 MB of heap space
to do this.  Why so much?


The class FreqProxTermsWriterPerField appears to be the biggest memory
consumer by far according to JConsole and the TPTP Memory Profiling
plugin for Eclipse Ganymede.


Example 2: Indexing a 62 MB text file runs out of memory with a 512 MB
max. heap size.  Increasing the max. heap size to 1024 MB works but
Lucene uses 826 MB of heap space while performing this.  Still seems
like way too much memory is being used to do this.  I'm sure larger
files would cause the error as it seems correlative.


I'm on a Windows XP SP2 platform with 2 GB of RAM.  So what is the best
practice for indexing large files?  Here is a code snippet that I'm


// Index the content of a text file.

      private Boolean saveTXTFile(File textFile, Document textDocument)
throws CIDBException {           


            try {             


                  Boolean isFile = textFile.isFile();

                  Boolean hasTextExtension =


                  if (isFile && hasTextExtension) {


                        System.out.println("File " +
textFile.getCanonicalPath() + " is being indexed");

                        Reader textFileReader = new

                        if (textDocument == null)

                              textDocument = new Document();

                        textDocument.add(new Field("content",



            } catch (FileNotFoundException fnfe) {


                  return false;

            } catch (CorruptIndexException cie) {

                  throw new CIDBException("The index has become

            } catch (IOException ioe) {


                  return false;


            return true;




Thanks much,




  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message