-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Original author: [email protected] (January 14, 2011 16:29:49)
- What steps will reproduce the problem?
- I believe you should be able to reproduce it by repeatedly reassigning a PImage with a new createGraphics(..., JAVA2D) statement. You don't need to do it quickly. One replacement every second or so for a minute should be enough to create a noticeable memory leak.
- What is the expected output? What do you see instead?
The output is as expected. I'm just leaking memory as well. - What version of the product are you using? On what operating system?
Processing 1.2.1 on Mac OSX 10.5.8. I'm writing the code in Eclipse with the Processing core library imported.
Please provide any additional information below.
I'm writing a game in which I need to generate some thumbnails (80x80ish). When something is updated, I have to generate a new thumbnail. Updates are happening once every few seconds. The PImage thumbnail is being replaced by a new one. Every time this happens I call createGraphics to grab myself a new picture to draw on. When I use this code:
thumbnail = M.P.createGraphics(thumbnailSize, thumbnailSize, M.P.P2D);
Everything runs fine. However, when I use the JAVA2D renderer
thumbnail = M.P.createGraphics(thumbnailSize, thumbnailSize, M.P.JAVA2D);
there is a substantial memory leak which takes down my JVM with an out of heap space error quite quickly. It only takes 50ish updates of the thumbnail. Every time I cause an update I watch (in the Mac Activity Monitor) as the memory consumption of my applet rises. After not too many updates I've risen from 100MB to 170MB.
I don't entirely understand the phenomenon. But, I'm reasonably sure it's not a problem with my code, because, like I said, if I replace JAVA2D with P2D it entirely goes away. (In Activity Monitor, the total memory consumption is essentially constant when I run the same code with P2D).
Original issue: http://code.google.com/p/processing/issues/detail?id=507