Running out of memory when generating PImages
in
Programming Questions
•
7 months ago
I was working on a little painting program that re-generates a bitmap on every frame, using a PImage object. This seems to cause the sketch to gobble up more and more RAM on each frame, until it runs out of memory and I get an error. Here is an example code that does the same thing but rendering random pixels:
Edit: I am using Processing 2.0b7
- PImage img;
void setup(){
size(250,250);
}
void draw(){
newImg();
image(img,0,0);
}
void newImg(){
img = createImage(250,250,ARGB);
img.loadPixels();
for(int x = 0; x < img.width; x++){
for(int y = 0; y < img.height; y++){
img.pixels[y * img.width + x] = color(random(255));
}
}
img.updatePixels();
}
Edit: I am using Processing 2.0b7
1