title: java outOfMemoryError with stringbuilder
body: <p>I'm getting a java outOfMemoryError when I call this method - i'm using it in a loop to parse many large files in sequence. my guess is that <code>result.toString()</code> is not getting garbage collected properly during the loop. if so, how should i fix it?</p>
  
  <pre><code>private String matchHelper(String buffer, String regex, String method){
      Pattern abbrev_p = Pattern.compile(regex);//norms U.S.A., B.S., PH.D, PH.D.
      Matcher abbrev_matcher = abbrev_p.matcher(buffer);
      StringBuffer result = new StringBuffer();
      while (abbrev_matcher.find()){
              abbrev_matcher.appendReplacement(result, abbrevHelper(abbrev_matcher));
      }
      abbrev_matcher.appendTail(result);
      String tempResult = result.toString(); //ERROR OCCURS HERE
    return tempResult;
  
  }
  </code></pre>