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

Atsushi Eno atsushi at ximian.com
Tue Nov 4 01:28:22 EST 2008


I think it is fixed at r117838 Can you try it and see if it's gone?

Thanks,
Atsushi Eno

Atsushi Eno wrote:
> 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
>>
> 
> _______________________________________________
> 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