title: CPU usage increases in time
body: <p>I am making game (asteroids, ship destroys asteroids by bullets) and I have a problem: <br> <br>
  If I spawn <strong>50 asteroids at start</strong>, cpu usage is about <strong>2-3%</strong>. Its OK. <br>
  But if I spawn <strong>5 asteroids</strong> and then I play the game and get to the moment when there is <strong>50 asteroids</strong> (increasing with each level, when you destoy all previous), CPU usage becomes about <strong>20%</strong> <br>
  In addition if I <strong>destroy 49/50 asteroid</strong> and <strong>leave only one</strong> alive, CPU usage will be <strong>still 20%</strong>, though there is nothing to compute ( I mean moving, collssion detection, etc.)</p>
  
  <p>I have the main <code>GameLoop TimerTask</code></p>
  
  <pre><code>public void startGameLoop() {
      timer.schedule(gameLoopTask, 0, 17);
      timer.schedule(updateScoreAndLifesTask, 2000, 300); // just update score views
  }
  class GameLoop extends TimerTask {
      public void run() {
          game.updateState();
          openGLView.requestRender();
      }
  }
  public void updateState() {
      ship.move();
  
      for(int i=0; i&lt;asteroids.size();i++) // asteroids and ship.bullets are ArrayLists
          asteroids.get(i).move();
  
      for(int i=0; i&lt;ship.bullets.size();i++)
          ship.bullets.get(i).move();
  
      detectCollision();
  }
  public void detectCollision() {
      detectCollisionAsteroidsWithBullets();
      if(ship.isAlive &amp;&amp; !ship.isImmortal)
          detectCollisionAsteroidsWithShip();     
  }
  </code></pre>
  
  <p>And <code>detectCollision</code> method loops the copy of <code>ship.bullets</code> and <code>asteroids</code> <code>ArrayLists</code>:</p>
  
  <pre><code>public void detectCollisionAsteroidsWithBullets() {
      mainloop: for(int b=0; b &lt; ship.bullets.size(); b++) {  
          for(int a=0; a&lt;asteroids.size(); a++) { 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public void detectCollisionAsteroidsWithShip() {        
      mainloop: for(int a=0; a&lt;asteroids.size(); a++) {
          if(isAABBoxIntersectWithAABBox(asteroids.get(a).AABBCoords, ship.AABBCoords)) {
  </code></pre>
  
  <p>So it shouldn't use CPU hard if there is <strong>only 1 asteroid</strong>. Destroying bullets and asteroids = <code>asteroids.remove(asteroid);</code> (I just remove it from ArrayList <br/>
  <br>
  So please, help me, I have no idea why it keeps using so much CPU if there is only loops that works prety good with 50 asteroids and for sure shouldn't do 20% CPU usage with only 1 asteroid</p>