I can reproduce that (similar setup). Already in 0195.
That said, the implementation is quite inefficient, the layout function calls intersects() repeatedly until it finds no intersection, but this function creates a PGrahics each time, of the size of the applet. This creates lot of garbage, faster than it can be collected, apparently. Not sure why it happens in 1.5 and not in 1.2.1, though.
I had to fix a similar issue at work (in a very different context, but yet creating a large amount of objects at once). I solved it by recycling lot of the objects instead of re-creating them. Not very Java-like, but it worked... Wordwookie could do the same, "washing" the PGraphics instead of re-creating it each time. Might also improve the performance...
Not sure what is the change bringing the issue... Perhaps these lines in paint():
- if (g != null) {
- // added synchronization for 0194 because of flicker issues with JAVA2D
- // http://code.google.com/p/processing/issues/detail?id=558
- if (g.image != null) {
- synchronized (g.image) {
- screen.drawImage(g.image, 0, 0, null);
- }
- }
- }
In general, we don't synchronize on the object we act on, we synchronize on an object created explicitly for this usage.
It might be possible that this usage prevents from garbage collecting the graphics? In 1.2.1, memory usage is around 10MB and stable, in 1.5 it peaks to 250 in a few seconds...
I should really start to build Processing, to avoid hypothesis and experiment with fixes.