title: Why does appending "" to a String save memory?
body: <p>I used a variable with a lot of data in it, say <code>String data</code>.
  I wanted to use a small part of this string in the following way:</p>
  
  <pre><code>this.smallpart = data.substring(12,18);
  </code></pre>
  
  <p>After some hours of debugging (with a memory visualizer) I found out that the objects field <code>smallpart</code> remembered all the data from <code>data</code>, although it only contained the substring.</p>
  
  <p>When I changed the code into:</p>
  
  <pre><code>this.smallpart = data.substring(12,18)+""; 
  </code></pre>
  
  <p>..the problem was solved! Now my application uses very little memory now! </p>
  
  <p>How is that possible? Can anyone explain this? I think this.smallpart kept referencing towards data, but why? </p>
  
  <p><strong>UPDATE:</strong>
  How can I clear the big String then? Will data = new String(data.substring(0,100)) do the thing?</p>