benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.35k stars 237 forks source link

curveVertex() causes OutOfMemory in P2D renderer #832

Open Real-John-Cheung opened 7 months ago

Real-John-Cheung commented 7 months ago
## Description

curveVertex() causes java.lang.OutOfMemoryError: Java heap space error when the vertex amount is big in P2D render. With the default Java2D render it works fine.

void setup(){
  size(800,800, P2D);
  beginShape();
  for(int i = 0; i < 26000;i ++){ 
    curveVertex(i * 0.1, 100);
  }
  endShape();
}

Above sketch crashes due to OutOfMemoryError, below sketches can be executed without problem:

void setup(){
  size(800,800);
  beginShape();
  for(int i = 0; i < 26000;i ++){ 
    curveVertex(i * 0.1, 100);
  }
  endShape();
}
void setup(){
  size(800,800, P2D);
  beginShape();
  for(int i = 0; i < 2000;i ++){ 
    curveVertex(i * 0.1, 100);
  }
  endShape();
}

Your Environment

Possible Causes / Solutions

Might have something to do with how Catmull-Rom splines is calculated in P2D?