title: I hit an OutOfMemoryException with List<string> - is this the limit or am I missing something?
body: <p>Given the opportunity to rewrite, I would, but anyway, the code as it stands:</p>
  
  <pre><code>List&lt;string&gt; foobar;
  </code></pre>
  
  <p>Then we add a bunch of strings to foobar.</p>
  
  <p>At count=16777216, we hit an out of memory limit.</p>
  
  <p>My understanding is that each string would be a different size. Indeed looking at the data (not my data), most are 2 or 3 characters.</p>
  
  <p><a href="https://stackoverflow.com/q/3906891/175051">what is the max limit of data into list in c#?</a> indicates that the max limit is:</p>
  
  <blockquote>
    <p>The maximum number of elements that can be stored in the current
    implementation of List is, theoretically, Int32.MaxValue - just
    over 2 billion.</p>
  </blockquote>
  
  <p>However:</p>
  
  <blockquote>
    <p>In the current Microsoft implementation of the CLR there's a 2GB
    maximum object size limit. (It's possible that other implementations,
    for example Mono, don't have this restriction.)</p>
  </blockquote>
  
  <p>In my example, I have, what, 16 million results * a few bytes?  Task manager shows about a gig being used, but I have 8 gigs of RAM.</p>
  
  <p>16777216 (2^24) seems like a fairly specific value - suspiciously like a limit, but I can't find any documentation anywhere to a) back this up or b) find a way around it?</p>
  
  <p>Any help would be appreciated.</p>
  
  <hr>
  
  <p>Some code:</p>
  
  <pre><code>List&lt;string&gt; returnList = new List&lt;string&gt;();
  SqlDataReader dr; //  executes a read on a database, have removed that part as that bit works fine
  
    if (dr.HasRows)
    {
        while (dr.Read())
        {
            returnList.Add(dr.GetString(0).Trim());
        }
    }
  </code></pre>
  
  <p>That's the simplified form, I now have some try/catch for the OOM Exception, but this is the actual code that's giving me grief.</p>