Memory Error when loading a big image folder in a processing sketch (about 1500 pictures)

edited September 2017 in Raspberry PI

I am loading a big image folder in a processing sketch (about 1500 pictures) using an example I found on open processing:

int maxImages = 1500; // Total # of images
int imageIndex = 0; // Initial image to be displayed is the first
boolean isPlaying = false;

// Declaring an array of images.
PImage[] images = new PImage[maxImages];

void setup() {
  size(1500, 1200);

  // Loading the images into the array
  // Don't forget to put the JPG files in the data folder!
  for (int i = 0; i < images.length; i ++ ) {
    images[i] = loadImage( "" + i + ".jpg" ); 
  }
}

void draw() {

  background(0);
  image(images[imageIndex],0,0);
}

I am getting a Memory Error even dialing it back to "int maxImages = 50;”

I have increased my memory in preferences, but it gives me another error “Make sure memory is not set too high” and also “can not run"

Same thing when testing on my laptop.

Any ideas? Is it just too many images?

Tagged:

Answers

  • Answer ✓

    It probably is too many images, especially on a pi. Remember that it's not the file size that matters (because image files are compressed) but the fact that internally images are stored as a byte per pixel.

    There was an example of using jcache to get around this but the last time I looked I only found dead links.

Sign In or Register to comment.