title: C# : the close method of Xml.Load(file)
body: <p>I have written some code that loads an XML document using an <code>XmlDocument</code> object so as to count it's nodes.  Here is the method:</p>
  
  <pre><code>XmlDocument xml = new XmlDocument();
  xml.Load(textBox1.Text);
  XmlNodeList nodes = xml.SelectNodes("//File");
  foreach (XmlNode node in nodes)
  {
      number_of_childs++;
  }
  </code></pre>
  
  <p>The problem that I am facing is, when importing a large file, it takes like 700MB of RAM.  If I then try to do some operation on the file, or even read from it to display its data in a <code>ListView</code>, the application takes like 2GB of RAM.  So, I was wondering, is there a method that closes the <code>XmlDocument</code> and frees its memory, releasing the RAM.  It is like it's forgetting to remove its content from memory.</p>