Bug 1368 : pushMatrix()-like limits and errors/warning for unmatched pushStyle()s?
Last modified: 2010-06-05 03:32




Status:
ASSIGNED
Resolution:
-
Priority:
P5
Severity:
enhancement

 

Reporter:
bakercp
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-11-05 18:43
1. Version 1.0.7
2. OSX 10.5.8 / MacBook Pro
3. Demo:

void setup() {
size(200,200);
background(0);
}

void draw() {
for(int i = 0; i < 10000; i++) {
pushStyle(); // unmatched
translate(100,100);
ellipse(0,0,20,20);
/* pushStyle() */ // accidentally forget it deep in your code somewhere
}

// memory being sucked away
Runtime r = Runtime.getRuntime();
println("(free) " + r.freeMemory() + " / (total)"+ r.totalMemory());

}

4. N/A
5. After many hours of debugging, I just discovered that my program was
running out of memory consistently because of an unmatched pushStyle()
(i.e. there was no matching popStyle()).

During the first few rounds of debugging I didn't think to look for
unmatched pushStyle()s, as I mistakenly assumed that they would throw a
similar error to unmatched pushMatrix()s that exceed the
MATRIX_STACK_DEPTH. Anyway, this may bot be considered a "bug" per se, but
rather a feature request.

The above program demonstrates what happened in my code (I had thousands of
instances of a particle object whose draw method included the unmatched
pushStyle()).
Additional Comment #1 From fry 2010-06-05 03:32
hm, most people consider it a feature that there are no limits, but i'll
make a note of it.
This bug is now being tracked here.