title: VB.Net XMLdocument memory management
body: <pre><code>Dim docu As New XmlDocument()
  docu.load("C:\bigfile.xml")
  
  Dim tempNode As XmlNode
  tempNode = docu.SelectSingleNode("/header/type")
  
  someArray(someIndex) = tempNode.innerText
  
  ...do something more...
  </code></pre>
  
  <p>I am using <code>XmlDocument()</code> to load a huge <code>XML</code> document (100~300MB)</p>
  
  <p>When I open the document and read it as <code>string</code>, my application uses about <em>900MB</em> of RAM.
  I wonder why it happens and how can I prevent it ?</p>
  
  <p>Note that : even, the <code>XmlDocument</code> does not have <code>Dispose()</code> to remove allocated things.
  Although I need the whole string of the huge XML file in later part of the app, the <code>/header/type.innerText</code> is only a single word</p>
  
  <hr>
  
  <p>More of source :</p>
  
  <pre><code>Private Sub setInfo(ByVal notePath As String)
  
          Dim _NOTE As XDocument
  
          _NOTE = XDocument.Load(notePath)
  
          If (From node In _NOTE...&lt;title&gt; Select node).Value = "" Then
              lvlist.Items.Add("No Title")
          Else
              lvlist.Items.Add((From node In _NOTE...&lt;title&gt; Select node).Value)
          End If
  
          lvlist.Items(lvlist.Items.Count - 1).SubItems.Add((From node In _NOTE...&lt;group&gt; Select node).Count)
  
  
  End Sub
  </code></pre>
  
  <p>It reads XML document, counts  tags and retrieves  string value. That's all.
  After having those values, _NOTE (XDocument) is of no use at that time.</p>