Out of Memory Error with BufferedReader

I try to read a file of around 900mb. I have set 2048mb available for processing (I have 16gig total).

loadStrings doesn't work but that's ok. However, I tried both on my pc and mac and BufferedReader doesn't work either.

An OutOfMemoryError means that your code is either using up too much memory because of a bug (e.g. creating an array that's too large, or unintentionally loading thousands of images), or that your sketch may need more memory to run. If your sketch uses a lot of memory (for instance if it loads a lot of data files) you can increase the memory available to your sketch using the Preferences window.

Why is this. Cause the documentation https://processing.org/reference/BufferedReader.html says > A BufferedReader object is used to read files line-by-line as individual String objects.

It's a kml file which should match utf-8 right?

BufferedReader reader;
String line;

void setup() {
  // Open the file from the createWriter() example
  reader = createReader("/Users/doekewartena/Desktop/WEGEN-NL.kml");    

void draw() {
  try {
    line = reader.readLine();
  } catch (IOException e) {
    line = null;
  if (line == null) {
    // Stop reading because of an error or file is empty
  } else {


  • I dunno what is a ".kml" file. Are you sure it's a human text file? /:)
    If not, much probably readLine() took so much time to find an end-of-line character and ran outta memory!

  • Kml is a xml for geo data, something like that. I will try to load the file in a text editor tommorow to see if the end lines are messed up. If i can find e texteditor that can open large files.

Sign In or Register to comment.