How to estimate memory need by XPathDocument for a specific xml file
Posted
by
bill seacham
on Stack Overflow
See other posts from Stack Overflow
or by bill seacham
Published on 2010-12-30T01:48:54Z
Indexed on
2010/12/30
1:54 UTC
Read the original article
Hit count: 255
c#
|xpathdocument
Is there any way to estimate the memory requirement for creating an XpathDocument instance based on the file size of the xml?
XpathDocument xdoc = new XpathDocument(xmlfile);
Is there any way to programmatically stop the process of creating the XpathDocument if memory drops to a very low level?
Since it loads the entire xml into memory, it would be nice to know ahead of time if the xml is too big. What I have found is that when I create a new XpathDocument with a big xml file, an outofmemory exception is never fired, but that the process slows to a crawl, only 5 Mb of memory remains a available and the Task Manager reports it is not responding. This happened with a 266 Mb xml file when there was 584 Mb of ram. I was able to load a 150 Mb file with no problems in 18.
After loading the xml, I want to do xpath queries using an XpathNavigator and an XpathNodeIterator. I am using .net 2.0, xp sp3.
© Stack Overflow or respective owner