title: ANDROID How to reduce String allocations
body: <p>I've managed to get my allocations down to next to nothing using DDMS (great tool), this has drastically reduced my GCs to about 1 or 2 every 3 minutes. Still, I'm not happy because those usually cause a noticeable delay in the game (on some phones) when you interact with it.</p>
  
  <p>Using DDMS, I know what the allocations are, they are Strings being converted from integers used to display game information to the HUD.</p>
  
  <p>I'm basically doing this:</p>
  
  <pre><code>int playerScore = 20929;
  String playerScoreText = Integer.toString(playerScore);
  canvas.drawText(playerScoreText, xPos, yPos);
  </code></pre>
  
  <p>This happens once each frame update and the HUD system is modular so I plug things in when I need and this can cause 4 or 5 hud elements to allocate Strings and AbstractStringBuilders in DDMS.</p>
  
  <p>Any way to reduce these further or eliminate all the String allocations and just reuse a String object?</p>
  
  <p>Thanks,
  Albert Pucciani</p>