Re: xml.xmldocument.load does it load document to memory?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tomas Restrepo \(MVP\) (tomasr_at_mvps.org)
Date: 03/05/04


Date: Fri, 5 Mar 2004 18:26:03 -0500


> I am making a simple app that groups files together by storing them into
an xml document. But here is my concern. The xml file that is being loaded
could be a gigabyte in size or it could just be 100k. So my question is that
if I use the xml.xmldocument.load method does the data in that document get
loaded into memory or does it stay on disk until you navigate down the nodes
hiarchy?

It gets loaded into memory COMPLETE in an in-memory tree representation, so
it's not suitable to handling very large files unless you have a LOT of
memory (this is not specifically a .NET problem, it is an issue with how the
DOM is supposed to work in general).

If you want your processing to be much more scalable, use the XmlReader
derived classes instead of loading it into the DOM (granted, it means more
work and will imply you can't do certain things... like XSLT
transformations)

--
Tomas Restrepo
tomasr@mvps.org


Relevant Pages

  • Re: xml.dom.minidom memory usage
    ... The DOM is such that it loads all the elements of the ... XML document into memory before you can do anything with it. ... SAX is such that it only reads the XML doc. ...
    (comp.lang.python)
  • Re: Optimizations to Reduce Memory Consumption and Minimize Paging
    ... wastes a lot of memory and the other version would just crash the OS, ... It seems the optimizations he added work, ... with that call still has a reference pointing to it (the problem is ... To prevent the XML document from constantly growing without any memory ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Reducing memory consumption
    ... it's eating more memory than a black hole. ... THe HTML files are less than ... The parsing is done using DOM (not DOM XML, as I wrote before, ...
    (comp.lang.php)
  • RE: Compact Framework bug?
    ... why do you think memory used by DOM is not released? ... GC does not have to run on method exit, but memory has to be released if ... writes the DOM object out to a new XML file ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Reducing memory consumption
    ... it's eating more memory than a black hole. ... The parsing is done using DOM (not DOM XML, as I wrote before, ... I'm using php 5. ...
    (comp.lang.php)