We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › clear Image Buffer
Page Index Toggle Pages: 1
clear Image Buffer (Read 479 times)
clear Image Buffer
Feb 27th, 2008, 11:47am
 
Hi,

I am currently working on a program that compares the pixels[] array of the stage with the pixels array of a PGraphics image buffer. I do that many times in a row and simply overwrite the PGraphics Object like this:

 nimg = createGraphics(width, height, JAVA2D);
 nimg.beginDraw();
 nimg.fill(0, 0, 0);
 nimg.smooth();
 nimg.noStroke();
 nimg.translate(x, y);
 nimg.rotate(random(PI));
 nimg.rect(-radius/2, -radius/2, radius, radius);
 nimg.endDraw();

the problem is, that after some time i get a java.lang.OutOfMemoryError: Java heap space even though I give Processing 1 GB of RAM to work with. So I guess the image buffer does not really get cleared so that after some time the 1GB are full and the error shows up.

Is there a work around for this problem?
Re: clear Image Buffer
Reply #1 - Feb 27th, 2008, 3:28pm
 
Is it because you create the buffer more than once?

Try calling createGraphics(...) only once in setup, and just calling fill(0, 0, 0) when you want to clear it.
Re: clear Image Buffer
Reply #2 - Feb 27th, 2008, 3:57pm
 
I think I solved it. the error was caused by something else i guess.-

thanks anyways!
Page Index Toggle Pages: 1