GWAK
October 26, 2022, 9:47pm
1
PImage fig_image;
long TIMER_RE = 0;
void setup(){
size(1000,1000);
fig_image = loadImage("fig_image.jpg");
}
void draw(){
if(TIMER_RE < millis()){
TIMER_RE = millis()+1000;
fig_image = loadImage("fig_image.jpg");
}
image(fig_image,0,0,width,height);
}
There is only one image variable, so why does the PC’s memory keep increasing? Any solution?
Images are often loaded. However, I don’t know why the ‘PC memory’ keeps increasing even though there is only one image stored in the variable.
Any solution?
jafal
October 26, 2022, 10:17pm
3
Hi
Try to make timer like this
int start;
int end ;
void setup() {
size(400,400);
}
void draw() {
//background(0);
start = millis() - end;
if (start >= 500) {
end = millis();
rect(10, 10, 180, 180);
}
}
1 Like
jafal
October 26, 2022, 10:28pm
4
Hi
I think you keep loop load image in void draw() thats why your memory low
1 Like
GWAK
October 26, 2022, 10:41pm
5
@jafal
Thank you for answer.
However, that’s not what I want.
This is the implementation of the above source code for testing.
1 Like
GWAK
October 26, 2022, 10:41pm
6
@GoToLoop
Thank you for answer.
There is a source code that can solve it. The problem is the delay.
there is a problem with lag.
void draw() {
if(TIMER_RE < millis()){
TIMER_RE = millis()+1000;
fig_image = null; System.gc();
fig_image = loadImage("fig_image.jpg");
}
image(fig_image, 0, 0, width, height);
}
GWAK
October 26, 2022, 11:01pm
7
@GoToLoop
I am making a ‘viewer program’ that allows you to zoom in and out through an image.
If you use ‘System.gc();’ like the video, a delay problem occurs.
If so, do you have any solution?
As seen in the video above,
‘System.gc();’ If you use , there will be lag.
The current implementation was made using the ‘get’ function in ‘image’.
If you have any solution, please let me know.