# Bug with processing. After running a program for about 5 hours

**URL:** <https://discourse.processing.org/t/bug-with-processing-after-running-a-program-for-about-5-hours/26975>\
**Category:** Processing\
**Created:** [January 11, 2021, 3:55pm UTC](https://discourse.processing.org/t/bug-with-processing-after-running-a-program-for-about-5-hours/26975 "2021-01-11T15:55:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [January 11, 2021, 3:55pm UTC](https://discourse.processing.org/t/bug-with-processing-after-running-a-program-for-about-5-hours/26975/1 "2021-01-11T15:55:39Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fa344c2d3b5559818f8872d9012cefad13a2fa57.png)

After I run the program for about 5 hours this happen; It is just a minor bug but yea : P, the total number of points probably exceeded the limits and so it started lagging.

```auto
ArrayList<PVector> pos = new ArrayList<PVector>();
float cx = 300, cy = 300, r = 300, dir = 0;
void setup() {
  size(600,600);
}
void draw() {
  background(0);
  fill(255);
  stroke(255);
  float x = cos(dir)*r, y = sin(dir)*r;
  circle(x+cx,y+cy,5);
  noFill();
  if(frameCount % 1 == 0) pos.add(new PVector(x+cx,y+cy));
  dir += (TWO_PI/7-0.0001)*10;
  beginShape();
  for(int i = 0; i < pos.size(); i++) vertex(pos.get(i).x, pos.get(i).y);
  endShape();
}
//void mousePressed() {
// pos.add(new PVector(mouseX,mouseY));
//}
//void keyPressed() { if(key == ' ') pos.clear();}
//void mouseDragged() {
// if(frameCount % 30 == 0) pos.add(new PVector(mouseX,mouseY));
//}

```

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [January 14, 2021, 5:50pm UTC](https://discourse.processing.org/t/bug-with-processing-after-running-a-program-for-about-5-hours/26975/2 "2021-01-14T17:50:15Z")

</div>

> [@CodeMasterX](#):
>
> `if(frameCount % 1 == 0) pos.add(new PVector(x+cx,y+cy));`

You keep adding vectors to the ArrayList. Sooner or later you’ll run out of memory and going through the huge ArrayList gets slower and slower. I’d say processing works as it should.

ArrayList can be used in this manner, but when user set max size has been reached an item is either replaced or one is deleted before new one is added.

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [January 14, 2021, 9:23pm UTC](https://discourse.processing.org/t/bug-with-processing-after-running-a-program-for-about-5-hours/26975/3 "2021-01-14T21:23:34Z")

</div>

I do realise it probably had several million PVectors in an array, but it still should work. No matter how many times it repeats there should be a black circle in the middle. In my opinion it is just a side effect of simplifying it.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 15, 2021, 11:50am UTC](https://discourse.processing.org/t/bug-with-processing-after-running-a-program-for-about-5-hours/26975/4 "2021-01-15T11:50:45Z")

</div>

Hello,

I have not explored to great depth but do see the same results after 5 minutes or so.

I tried “kind” = LINES or POINTS in beginShape(kind) and nothing unusual yet!  
I did see the same behavior as yours with just beginShape().

[https://processing.org/reference/beginShape\_.html](https://processing.org/reference/beginShape_.html)

My initial exploration:

```auto
ArrayList<PVector> pos = new ArrayList<PVector>();

float cx = 250, cy = 250, r = 250, dir = 0;
  
float angle;  
  
PVector v1;  
  
void setup() 
  {
  size(600, 600);
  angle = (TWO_PI/7-0.0001)*10;  
  v1 = new PVector(250, 0, 0);
  println(angle);
  background(0);
  }

void draw() 
  {
  background(0);
  
  translate(width/2, height/2);
  
  fill(255);
  stroke(255);
  //float x = cos(dir)*r; 
  //float y = sin(dir)*r;
  //strokeWeight(5);
  //point(x+cx, y+cy);
  
  point(v1.x, v1.y);
  
  v1.rotate(angle);
  
  noFill();
  //if(frameCount % 1 == 0) 
    pos.add(new PVector(v1.x, v1.y));
  
  dir += angle;
  
  //beginShape(); 
  //beginShape(POINTS);
  beginShape(LINES);
  for(int i = 0; i < pos.size(); i++) 
    vertex(pos.get(i).x, pos.get(i).y);
  endShape();
  
  if(frameCount % 100 == 0) 
    println(frameCount, frameRate);
  }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f82e63da19f37b085d471fac5eea25d48c4a0e76.jpeg)

`:)`
