[Mono-bugs] [Bug 42757][Nor] New - Xsl Memory Leak

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sat, 10 May 2003 22:02:06 -0400 (EDT)


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 bmaurer@users.sf.net.

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

--- shadow/42757	Sat May 10 22:02:06 2003
+++ shadow/42757.tmp.5992	Sat May 10 22:02:06 2003
@@ -0,0 +1,91 @@
+Bug#: 42757
+Product: Mono/Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Xsl Memory Leak
+
+Description of Problem:
+There seems to be a memory leak when performaing xsl transformations. The
+bug is demonstrated in a program that loops the steps of performing a
+transformation. Even though GC.Collect () is called once every 100
+transformations, memory is not reclaimed.
+
+Steps to reproduce the problem:
+1. Compile this program:
+>>
+using System;
+using System.Threading;
+using System.Xml;
+using System.Xml.Xsl;
+using System.Xml.XPath;
+
+public class NetXsltProc {
+	
+	public static void Main (string [] args) {
+		if (args.Length == 2)
+			Transform (args [0], args [1]);
+		else
+			Console.WriteLine ("Usage: mono netxsltproc.exe <xsl> <xml>");
+		
+		GC.Collect ();
+		Thread.Sleep (1000000);
+	}
+	
+	public static void Transform (string XmlFile, string XslFile) {
+
+			
+		for (int i = 0; i < 50000; i++) {
+			XslTransform xslt = new XslTransform ();
+			XPathDocument xml = new XPathDocument (XslFile);
+			XmlWriter output = new XmlTextWriter (Console.Out);
+			
+			xslt.Load (XmlFile);
+			xslt.Transform (xml, null, output);
+			if (i % 100 == 99) GC.Collect ();
+		}
+	}
+}
+<<
+Add these files to your the directory. The bug is not specific to these
+files, but these files do demonstrate the bug:
+>>
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+	<xsl:template match="node()|@*">
+		<xsl:copy>
+			<xsl:apply-templates select="@*"/>
+			<xsl:apply-templates/>
+		</xsl:copy>
+	</xsl:template>
+	
+</xsl:stylesheet>
+<<
+>>
+<this>
+	<is /> <an /> <xml /> <document />
+</this>
+<<
+2. Transform the file using the c# program 
+
+Actual Results:
+Results of transformation are shown, but memory consumption increases
+dramaticly.
+
+Expected Results:
+Results shown with minimal memory usage.
+
+How often does this happen? 
+Always.