title: How to avoid high memory usage in Phaser game using Cordova?
body: <p>I have developed a Cordova Phaser game. It runs in Android and iOS devices.</p>
  
  <p>The game has seven levels, with each level having a number of sprite (background, player) and groups (bullets, enemies).</p>
  
  <p>In <code>preload</code> function, I have loaded all images and atlasJSONHash</p>
  
  <pre><code>function preload(){
      game.load.atlasJSONHash('anim', 'anim.png', 'anim.json');
      //and so on
  }
  
  function create(){
       var star = game.add.sprite(160, 32, 'level1bg');
       star.x = 0;
       star.y = 0;
       star.height = game.height;
       star.width = game.width;
  
       bullets = game.add.group();
       bullets.enableBody = true;
       bullets.physicsBodyType = Phaser.Physics.ARCADE;
  
       bullets.createMultiple(30, 'bullet');
       bullets.setAll('anchor.x', 0.5);
       bullets.setAll('anchor.y', 1);
       bullets.setAll('outOfBoundsKill', true);
       bullets.setAll('checkWorldBounds', true);
       //and so on
  }
  function startlevel(level)
  {
       var star = game.add.sprite(160, 32, 'level1bg');
       star.x = 0;
       star.y = 0;
       star.height = game.height;
       star.width = game.width;
  
       bullets = game.add.group();
       bullets.enableBody = true;
       bullets.physicsBodyType = Phaser.Physics.ARCADE;
  
       bullets.createMultiple(30, 'bullet');
       bullets.setAll('anchor.x', 0.5);
       bullets.setAll('anchor.y', 1);
       bullets.setAll('outOfBoundsKill', true);
       bullets.setAll('checkWorldBounds', true);
       //and so on
  }
  </code></pre>
  
  <p>When the level ends I call <code>startlevel(2)</code> and so on.</p>
  
  <p>In browser it runs fine, but in mobile memory doubles for each level, with the app eventually crashing. How do I avoid this memory problem?</p>