title: OutofMemoryException while reading large XML file in C# windows forms
body: <p>I have been storing the .png files into one of the XML element as below. I have been converting the image file into base64 and then copying that string to XML. I was also able to read.load this XML file into my window form. The issue I am facing is as the XML file is growing with more nodes, XML file size has grown too large, right now it is 300 MB. When the Windows forms is trying to read this large XML file I am getting <code>OutOfMemoryExceptions</code>.
  Below is the snippet of my xml file.</p>
  
  <pre><code>&lt;TestResult&gt;
      &lt;ResultsID&gt;49&lt;/ResultsID&gt;
      &lt;DateExecuted&gt;2018-02-20T09:36:12.787&lt;/DateExecuted&gt;
      &lt;UserExecuted&gt;xxx&lt;/UserExecuted&gt;
      &lt;CorrectedMean&gt;1966.32245&lt;/CorrectedMean&gt;
      &lt;CorrectedVariance&gt;19525.6632019949&lt;/CorrectedVariance&gt;
      &lt;TestPassed&gt;true&lt;/TestPassed&gt;
      &lt;TestResultImage&gt;Qk2.......&lt;/TestResultImage&gt;
  &lt;/TestResult&gt;
  </code></pre>
  
  <p>I have been trying to load the XML into .net using the below code</p>
  
  <pre><code>XDocument xmlResultsDoc = XDocument.Load("MeanData.xml");
  </code></pre>
  
  <p>and storing into my model class as below.</p>
  
  <pre><code>List&lt;MeanVarianceTestResultDataList = 
  (xmlResultsDoc.Descendants("TestResult").Select(m =&gt; new 
  MeanVarianceTestResultsData()
                      {
                          ResultsID = 
  Convert.ToInt32(m.Element("ResultsID").Value),
                          DateExecuted = 
  Convert.ToDateTime(m.Element("DateExecuted").Value),
                          UserExecuted = 
  Convert.ToString(m.Element("UserExecuted").Value),
                          CorrectedMean = 
  Convert.ToString(m.Element("CorrectedMean").Value),
                          CorrectedVariance = 
  Convert.ToString(m.Element("CorrectedVariance").Value),
                          TestPassed = 
  Convert.ToBoolean(m.Element("TestPassed").Value),
                          TestResultImage =  
  
  Convert.FromBase64String(
  Convert.ToString(m.Element("TestResultImage").Value))
                      })).ToList();
  </code></pre>