469,601 Members | 2,172 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

Does the XMLDocument.Load(System.IO.Stream) method load the whole

The description of the XMLDocument.Load method doesn't quite answer the
question. When passing in a FileStream object to the Load method, does it
load the entire document into memory? For example, if I have a 1 gigabyte
file, would the Load method attempt read the entire 1 gigabyte file into
memory when using a FileStream object?
Sep 12 '08 #1
1 2902
Shawn Sesna wrote:
The description of the XMLDocument.Load method doesn't quite answer the
question. When passing in a FileStream object to the Load method, does it
load the entire document into memory?
Yes. The kind of stream doesn't matter, actually, it will pull data from the
stream until it's read a complete document.
For example, if I have a 1 gigabyte file, would the Load method attempt
read the entire 1 gigabyte file into memory when using a FileStream
object?
It wouldn't actually read all of the file into memory, it would read it
piecewise and construct an in-memory representation of the XML document it
represents while it's doing so. This will end up quite a bit larger than 1
GB, actually. This is why XmlDocument is unsuitable for very large streams.
XmlReader and XPathNavigator are light-weight alternatives.

--
J.
Sep 12 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Matthew Wieder | last post: by
3 posts views Thread by Uldis V. | last post: by
3 posts views Thread by ek03 | last post: by
5 posts views Thread by Mahmoud Al-Qudsi | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.