OutOfMemory error when using Apache Commons lineIterator
问题 I'm trying to iterate line-by-line a 1.2GB file using Apache Commons FileUtils.lineIterator . However, as soon as a LineIterator calls hasNext() I get a java.lang.OutOfMemoryError: Java heap space . I've already allocated 1G to the java heap. What am I doing wrong in here? After reading some docs, isn't LineIterator supposed to be reading the file from the file system and not loading it into memory? Note the code is in Scala: val file = new java.io.File("data_export.dat") val it = org.apache