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

Atsushi Eno atsushi at ximian.com
Mon Nov 3 15:36:35 EST 2008


Hello,

Thanks Sasha, I'll have a look. It looks like only about XmlTextReader,
and once I find the culprit it wouldn't be hard to fix.

Atsushi Eno


Sasha Kogan wrote:
> Hi,
> 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))
> 	    doc.ReadNode(xmlReader);
> 	else
> 	    xmlReader.Read();
>     }
> }
> 
> on a large (let's say, ~0.5GB) xml structured like this:
> 
> <RootElem>
>    <Elem TestAttrib="Some text some text some text"/>
>    ...
>    ...
>    <Elem TestAttrib="Some text some text some text"/>
> </RootElem>
> 
> 
> 
> 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?
> 
> TIA,
> 
> 
> /Sasha
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 



More information about the Mono-devel-list mailing list