Ok. I made some measurements of memory needs for image displaying. And I'm quite astonished that it needs so much RAM to display few images.
The smallest program I could think of with the OpenGL library uses 39 MB. Here's the code:
Code:
import processing.opengl.*;
PImage i1,i2,i3,i4,i5,i6,i7,i8,i9;
int i=1;
void setup(){
size(1024,768,OPENGL);
hint(ENABLE_OPENGL_2X_SMOOTH);
background(0);
void draw(){
}
If I only *load* (no displaying yet) 7 images (1.53 MB for all 7 files) this sample sketch uses 82MB according to windows task manager.
Code:
import processing.opengl.*;
PImage i1,i2,i3,i4,i5,i6,i7,i8,i9;
int i=1;
void setup(){
size(1024,768,OPENGL);
hint(ENABLE_OPENGL_2X_SMOOTH);
background(0);
i1=loadImage("pr/1.png");
i2=loadImage("pr/2.png");
i3=loadImage("pr/3.png");
i4=loadImage("pr/4.png");
i5=loadImage("pr/5.png");
i6=loadImage("pr/6.png");
i7=loadImage("pr/7.png");
}
void draw(){
}
Then if I display:
image 1 - 114
image 2 - 122
image 3 - 140
image 4 - 165
image 5 - 156
image 6 - 185
image 7 - 225
The values vary a bit, but not by much, maybe +/- 5MB.
Here's the code:
Code:
import processing.opengl.*;
PImage i1,i2,i3,i4,i5,i6,i7,i8,i9;
int i=1;
void setup(){
size(1024,768,OPENGL);
hint(ENABLE_OPENGL_2X_SMOOTH);
background(0);
i1=loadImage("pr/1.png");
i2=loadImage("pr/2.png");
i3=loadImage("pr/3.png");
i4=loadImage("pr/4.png");
i5=loadImage("pr/5.png");
i6=loadImage("pr/6.png");
i7=loadImage("pr/7.png");
}
void draw(){
}
void mouseClicked(){
switch(i){
case 1: image(i1,0,0,1024,768);
i++;
break;
case 2: image(i2,0,0,1024,768);
i++;
break;
case 3: image(i3,0,0,1024,768);
i++;
break;
case 4: image(i4,0,0,1024,768);
i++;
break;
case 5: image(i5,0,0,1024,768);
i++;
break;
case 6: image(i6,0,0,1024,768);
i++;
break;
case 7: image(i7,0,0,1024,768);
i++;
break;
}
}
How can this be so inefficient? I mean, using over 200 MB of RAM just to load 7 images while displaying only 1?
Why does the RAM keep adding up even when my images are already loaded and I'm just displaying a different one each time? Maybe an OpenGL bug?
**********EDIT********
I even tried using a jpg image instead of PNG with the same results.
Also, it's not only doing it in my developing computer, but in others as well. :/
JohnG, I know you can shed some light on this