title: Avoid memory leaks with strings
body: <p>I've found a memory leak in my parser. I don't know how to fix that problem.
  Let's see that basic routing.</p>
  
  <pre><code>    private void parsePage() {
          String[] tmp = null;
  
          foreach (String row in rows) {
              tmp = row.Split(new []{" "}, StringSplitOptions.None);
  
              PrivateRow t = new PrivateRow();
  
              t.Field1 = tmp[1];
              t.Field2 = tmp[2];
              t.Field3 = tmp[3];
              t.Field4 = String.Join(" ", tmp);
  
              myBigCollection.Add(t);
          }
      }
  
  
      private void parseFromFile() {
          String[] tmp = null;
  
          foreach (String row in rows) {
              PrivateRow t = new PrivateRow();
  
              t.Field1 = "mystring1";
              t.Field2 = "mystring2222";
              t.Field3 = "mystring3333";
              t.Field4 = "mystring1 xxx yy zzz";
  
              myBigCollection.Add(t);
          }
      }
  </code></pre>
  
  <p>Launching <strong>parsePage()</strong>, on a collection (rows is a List of 100000 elements) make my app grown from 20MB to 70MB.</p>
  
  <p>Launching <strong>parseFromFile()</strong>, that read SAME collection from file, but avoiding split/join, take about 1MB.</p>
  
  <p>Using a MemoryProfiler, I see that <strong>"t" fields and PrivateRow</strong>, kkep reference to String.Split() array and Split.Join.
  I suppose that's because I assign a reference, not a copy, that can be garbage collected.</p>
  
  <p>Ok, use 70mb isn't a big deal, but when I launch on production, with a lot o site, it can raise 2.5-3GB...</p>
  
  <p>Cheers</p>