Memory leak getting buffer image with OpenGL in Processing 2.0+?
in
Core Library Questions
•
1 year ago
I have came across an issue trying to draw to a buffer and then immediately grabbing its image and displaying it. However when I get the PImage of the buffer, the framerate and computer resources gradually decrease until my computer essentially becomes unusable. I am on OSX Snow Leopard, here is my code:
- PGraphics pg;
PImage pgImg;
int w = 500;
int h = 500;
void setup(){
size(w, h, OPENGL);
pg = createGraphics(w, h);
}
void draw(){
// drawing in the buffer doesnt need to be done
// the issue is still evident without it
pg.beginDraw();
pg.fill(255, 0, 0);
pg.rect(0, 0, w, h);
pg.endDraw();
- // Issue only happens when the image is grabbed from pg
pgImg = pg.get(0, 0, pg.width, pg.height);
image(pgImg, 0, 0);
println(frameRate);
}
If I draw the the buffer pg directly instead of grabbing its PImage, then it works fine. However the reason why I need to grab the PImage instead of drawing the buffer directly into image() is because I need to apply an alpha mask to it before its displayed (I left that out to isolate the issue). It also works fine when I remove OpenGL, however OpenGL is required for my project. Is this an ongoing issue with Processing 2.0+ or is there a way I can achieve this without it leaking?
1