Article ID: 293080 - Last Review: October 16, 2002 - Revision: 1.4

FIX: Memory Leak on addParameter with Cached XSL Template at ASP Application Level

This article was previously published under Q293080

On This Page

Expand all | Collapse all

SYMPTOMS

After you add an XMLDOMDocument or XMLDOMNode object to an Extensible Stylesheet Language (XSL) template that is cached in an Active Server Pages (ASP) Application variable, and you set an XSLProcessor object in a second ASP page to use the cached Application level template as a parameter, the XSLProcessor object's transform method consumes a large amount of memory.

You only see memory usage grow if the XSL template is cached at the ASP Application level. You do not see the memory leak if you create a new XSL template every time that the XSLProcessor object is used.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Microsoft XML 3.0 Service Pack 1.

For additional information on other fixes included in Microsoft XML 3.0 Service Pack 1, click the article number below to view the article in the Microsoft Knowledge Base:
292935  (http://support.microsoft.com/kb/292935/EN-US/ ) INFO: List of Issues Fixed in Microsoft XML 3.0 Service Pack 1
For the latest information and downloads of MSXML, refer to the following MSDN Web site at:
http://msdn.microsoft.com/xml/default.asp (http://msdn.microsoft.com/xml/default.asp)

MORE INFORMATION

Steps to Reproduce Behavior

  1. Save the following code as File1.asp:
    <%
    '=============================================
    ' File1.asp - Run once to cache the template
    ' in an Application object.
    
    Dim oXSLDocument
    Set oXSLDocument = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
    oXSLDocument.async = False
    oXSLDocument.load(Server.MapPath("test.xsl"))
    
    Dim oXSLTemplate
    Set oXSLTemplate = Server.CreateObject("MSXML2.XSLTemplate.3.0")
    Set oXSLTemplate.stylesheet = oXSLDocument
    
    Set Application("CachedTemplate") = oXSLTemplate
    
    Set oXSLDocument = Nothing
    Set oXSLTemplate = Nothing
    %>
    					
  2. Save the following code as File2.asp:
    <%
    '=============================================
    ' File2.asp - Each run consumes memory, without
    ' releasing it.
    
    Dim oInputDoc
    Dim oResourceDoc
    Dim oXSLProcessor
    
    Set oInputDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
    oInputDoc.loadXML "<Test>" & Now() & "</Test>"
    
    Set oResourceDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
    oResourceDoc.loadXML "<Resources/>"
    
    Set oXSLProcessor = Application("CachedTemplate").createProcessor()
    oXSLProcessor.input = oInputDoc
    oXSLProcessor.output = Response
    
    'Remove this line to stop the leak.
    oXSLProcessor.addParameter "resources", oResourceDoc.documentElement
    
    oXSLProcessor.transform()
    
    Set oResourceDoc = Nothing
    Set oInputDoc = Nothing
    Set oXSLProcessor = Nothing
    %>
    					
  3. Save the following code as Test.xsl:
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    	<xsl:template match="/">
    	  XSL output: <xsl:value-of select="Test" />
    	</xsl:template>
    </xsl:stylesheet>
    					
  4. Test the application under stress:
    1. Set up a new virtual folder and copy File1.asp, File2.asp, and Test.xsl to the virtual folder.
    2. Configure the new virtual folder to run in High Isolation - Out of Process, so that the ASP application runs under a separate copy of Dllhost.exe.
    3. From your browser, run File1.asp.
    4. From your browser, run File2.asp repeatedly.
    5. To view memory usage, start Windows Task Manager and click the Processes tab. One instance of Dllhost.exe shows linear growth in memory usage, corresponding to the memory leak.

APPLIES TO
  • Microsoft XML Parser 3.0
Keywords: 
kbbug kbfix kbmsxml300sp1fix kbmsxmlnosweep KB293080
 

Article Translations