OutOfMemory PImage/PGraphics problem
in
Programming Questions
•
1 year ago
First off, I jus wanna say thanks to everybody on these forums for their help with the issues I have posted up in the past few weeks.
Secondly, I have another issue..
(
sample code in first reply)
I am currently working on a drawing application that uses a png image as its "ink".
The image is loaded into a PImage variable called "pen1" at the begining of the program.
When the user pressed down on the mouse the image is drawn to a JAVA2D PGRAPHICS at mousex,mousey.
The image itself is only 20*20 pixels.
Also, if i replace:
- image(pen1,mouseX,mouseY,20,20);
with:
- rect(mouseX,mouseY,20,20);
..it works fine..
It works fine for about 50-100 draws and then it crashes with the following error:
- An OutOfMemoryError means that your code is either using up too much memory
- because of a bug (e.g. creating an array that's too large, or unintentionally
- loading thousands of images), or that your sketch may need more memory to run.
- If your sketch uses a lot of memory (for instance if it loads a lot of data files)
- you can increase the memory available to your sketch using the Preferences window.
- Exception in thread "Animation Thread" java.lang.OutOfMemoryError: Java heap space
1