[Mono-bugs] [Bug 80306][Nor] New - XmlTextReader.ReadChars uses a lot of memory with large text nodes

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Dec 18 14:29:09 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by csaba.halasz at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80306

--- shadow/80306	2006-12-18 14:29:09.000000000 -0500
+++ shadow/80306.tmp.27396	2006-12-18 14:29:09.000000000 -0500
@@ -0,0 +1,66 @@
+Bug#: 80306
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: Csaba.Halasz at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlTextReader.ReadChars uses a lot of memory with large text nodes
+
+Description of Problem:
+XmlTextReader.ReadChars internally stores the read text consuming a lot of
+memory.
+
+Steps to reproduce the problem:
+1. Create an xml document with a large text node (100MB will do nicely :))
+2. Read the node using XmlTextReader.ReadChars() in small blocks (1kB)
+(see attached test case)
+
+Actual Results:
+Observe increasing memory consumption (totalling 520MB on my test system)
+
+Expected Results:
+Minimal and more-or-less constant memory consumption.
+
+How often does this happen? 
+Always.
+
+Additional Information:
+As far as I can see this bug is caused by not clearing the
+preserveCurrentTag flag. Naive fix attached.
+
+Note that ReadChars() is specifically intended to be used with large text
+nodes so I think it is a reasonable expectation that this should work.
+
+Also note that memory consumption occurs even if simply reading through the
+xml with successive calls to Read(). That is without actually retrieving
+the contents of the node. I am not familiar enough with the code to offer a
+fix for this, but I think skipping through a large text node should not use
+up memory (I have checked this eats memory under windows as well).
+
+I have used heap-buddy to look at the memory statistics. Strangely, it
+reports "798 live objects using 256.1M" at exit.
+Backtrace info looks like this:
+
+                    Backtrace                      #  Total    AvSz    AvAge
+
+                                      type=char[] 17 512.0M 31580432.9   1.1
+          System.Xml.XmlTextReader:ReadTextReader                           
+                System.Xml.XmlTextReader:PeekChar                           
+       System.Xml.XmlTextReader:ReadCharsInternal                           
+               System.Xml.XmlTextReader:ReadChars                           
+                                 Test02.Test:Main          
+
+I am totally puzzled by this. Is there any way to dump the live objects at
+exit?
+
+Test configuration: mono 1.2.2.1, x86_64, LARGE_CONFIG GC


More information about the mono-bugs mailing list