title: Out of memory exception
body: <p>I have a list of a class type which contains (string, string, string, string, int, DateTime, DateTime)
  The total amount of chars in the strings combined equals 28.</p>
  
  <p>I read in a file to populate the list which will finish with 19,000,000 (nineteen-million) of these objects in the list. </p>
  
  <p>I read in the file and add to the list like so</p>
  
  <pre><code>public void ReadDocGrabValues(string fileREAD)
  {
      using (var file = new StreamReader(fileREAD))
      {
          var j = file.ReadLine();
  
          while (j != null)
          {
              mylist.Add(new IDandAGE(j.Substring(0, 15), j.Substring(16, 1), j.Substring(18, 6), j.Substring(25, 6), 0, DateTime.Today, DateTime.Today));
              j = file.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>Which shouldn't be the problem. I then go through the entire list to work out the DateTime objects from the two strings.</p>
  
  <pre><code>public void ConvertYOBDOI()
  {
      foreach (IDandAGE x in mylist)
      {
          string IssueDate = (x.StringDOD.Substring(0,4) + "-" + x.StringDOD.Substring(4,2) + "-01");
          string BirthDate = (x.StringYOB.Substring(0,4) + "-" + x.StringYOB.Substring(4,2) + "-01");
          x.DeathDate= DateTime.Parse(DeathDate);
          x.YearOfBirth = DateTime.Parse(BirthDate);
  
       }
  }
  </code></pre>
  
  <p>I then go through the entire list again to work out the age value.</p>
  
  <pre><code>public void DateCalc()
  {
      foreach (IDandAGE w in mylist)
      {
          w.Age = w.DateOfDeath.Year - w.YearOfBirth.Year;
          if (w.YearOfBirth &gt; w.DateOfDeath.AddYears(-w.Age)) w.Age--;
  
      }
  }
  </code></pre>
  
  <p>And finally I write out the values I want from the list to a file.</p>
  
  <pre><code>public void CreateAgeFile()
  {
     StreamWriter a = new StreamWriter(@"C:\GetAgeTest.txt");
  
      foreach (IDandAGE x in mylist)
      {
         String f = (x.ID + "," + x.Gender + "," + x.StringYOB + "," + x.StringDOD + "," + x.Age + ",NULL,NULL,NULL");
          a.WriteLine(f);
      }
      a.Close();
  
  }
  </code></pre>
  
  <p>I've really only just started coding so apologies in advance for it being inefficient/rubbish/not being able to answer my own question.</p>
  
  <p>I guess it's possible that it's giving me this exception for multiple reasons since I traverse through the list several times. </p>
  
  <p>Any help or suggestions welcomed. </p>
  
  <p>Thank you.</p>