[Mono-dev] XmlDocument.ReadNode() causes huge memory consumpsion by XmlTextReader

Sasha Kogan sashak at mainsoft.com
Mon Nov 3 09:47:20 EST 2008

I get OutOfMemoryError (I use Grasshopper, but the problem is not
Java-specific) when running the following code:

void runTest(string filename)
    XmlDocument doc = new XmlDocument();
    XmlReader xmlReader = XmlReader.Create(filename);

    while (!xmlReader.EOF)
	if ((xmlReader.NodeType == XmlNodeType.Element) &&
(xmlReader.Depth == 1))

on a large (let's say, ~0.5GB) xml structured like this:

   <Elem TestAttrib="Some text some text some text"/>
   <Elem TestAttrib="Some text some text some text"/>

I can see that XmlTextReader.ClearValueBuffer() is never called in this
case, so the attribute values of all processed elements are accumulated
in XmlTextReader.valueBuffer.

Would it be difficult to fix?



More information about the Mono-devel-list mailing list