I have written some code that loads an XML document using an XmlDocument
object so as to count it's nodes. Here is the method:
XmlDocument xml = new XmlDocument();
xml.Load(textBox1.Text);
XmlNodeList nodes = xml.SelectNodes("//File");
foreach (XmlNode node in nodes)
{
number_of_childs++;
}
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 ListView
, the application takes like 2GB of RAM. So, I was wondering, is there a method that closes the XmlDocument
and frees its memory, releasing the RAM. It is like it's forgetting to remove its content from memory.