|
| Massive memory use by XmlDocument |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.framework.performance.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| James O (VIP) |
| GOOD ANSWER |
I wrote a very simple test program that opens an XML document then releases the reference to it:
static void Main(string[] args) { XmlDocument doc = null; using (Stream s = File.OpenRead(args[0])) { doc = LoadXmlDocFromStream(s); }
doc = null; Console.ReadLine(); }
protected static XmlDocument LoadXmlDocFromStream(Stream s) { XmlDocument d = new XmlDocument(); d.PreserveWhitespace = false; XmlTextReader reader = new XmlTextReader(s); d.Load(reader); reader.Close();
return d; }
When I open a 20MB XML doc, I see through the CLR profiler that my CLR memory usage jumps from 6K to a whopping 90MB. My working set size as shown by the Task Manager jumps from 8MB to 210MB!
What's even more disturbing than these numbers is that when I release the reference to the object, the CLR memory goes back down to 6K, but my working set size remains at about 200MB! That just seems wrong.
|
|
|
| |
|
|
| |
| |
| Andy Becker |
| GOOD ANSWER |
"James O" <James Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
Given that XML is about 90% redundant data, I'm not too surprised at the bloat.
Don't worry too much about what shows up in task manager, that memory gets returned to the OS when other applications request it.
Best Regards,
Andy
|
|
|
| |
|
|
| |
|
| |
| David Browne |
| GOOD ANSWER |
"James O" <James Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... > I wrote a very simple test program that opens an XML document then releases [Original message clipped]
.. . .
[Original message clipped]
You have discovered that XMLDocument is not an appropriate type for manipulating very large XML documents. Try the streaming XMLReader instead.
David
|
|
|
| |
|
|
| |
| |
| Dathon |
| GOOD ANSWER |
Yeah, but there's bad and there's just plain broken. The huge memory consumption is coming from somewhere other than the CLR heap, which is very suspicious, IMO.
Any 'softies out there who know the inside scoop on this one?
Thx, James
"David Browne" wrote:
[Original message clipped]
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|