Microsoft KB Archive/291844

= PRB: ISAXXMLReader::parseURL Consumes Large Amount of Memory Over HTTP =

Article ID: 291844

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft XML Core Services 4.0
 * Microsoft XML Parser 3.0 Service Pack 1
 * Microsoft XML Core Services 4.0

-



This article was previously published under Q291844



SYMPTOMS
When you use code such as the following, note that the parseURL method of the SAXXMLReader object consumes an unexpectedly large amount of memory when parsing a large XML file over HTTP: Set saxReader = CreateObject(&quot;Msxml2.SAXXMLReader.3.0&quot;) saxReader.putFeature &quot;server-http-request&quot;, true

saxReader.parseURL &quot;http://localhost/big.xml&quot; You expect that the parseURL method would not consume much more memory than the actual size of the XML file.



CAUSE
The current implementation of the WinHttpRequest component that is used by the ServerXMLHTTP object does not support &quot;pull&quot; semantics for retrieving the response data; that is, the WinHTTPRequest does not support fetching the response off the wire in chunks. As a result, the response data gets double buffered in the WinHttpRequest component.

The component itself maintains one copy internally and then makes a second copy to make the responseText, responseBody, and responseStream properties available for use with scripting languages. The double buffering may lead to large memory footprints when using the Simple API for XML (SAX) or Document Object Model (DOM) components to process large XML files over HTTP.



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

Memory usage is reduced when you use Microsoft XML version 3.0, Service Pack 1 or MSXML 4.0.



Steps to Reproduce Behavior
 Create the large XML document about 100 MB in size by following these steps:  In Microsoft Visual Basic, create a new Standard EXE project. Form1 is created by default. Add a Command button to Form1. Command1 is created by default.  Paste the following code into the Click event for Command1: On Error GoTo handler Open &quot;c:\inetpub\wwwroot\big.xml&quot; For Output As #1 Print #1, &quot;&quot; Print #1, &quot;&quot; Dim i As Long For i = 1 To 100000 Print #1, &quot;&quot; & String(1000, &quot;o&quot;) & &quot;</t>&quot; Next i Print #1, &quot;</XML>&quot; Close #1 Exit Sub handler: MsgBox Err.Number & &quot;:&quot; & Err.Description, vbExclamation, Err.Source </li> Create the test VBScript file: Paste the following code into the new text file:

To run the code with MSXML 4.0 parser, change:

Set saxReader = CreateObject(&quot;Msxml2.SAXXMLReader.3.0&quot;)

To

Set saxReader = CreateObject(&quot;Msxml2.SAXXMLReader.4.0&quot;)

</li> Press the F5 key to run the project from Visual Basic.

NOTE:The program creates a file of about 100 MB in size. The program takes quite a while to run. Be sure that you have sufficient free hard disk drive space. Be sure to delete the XML file after you complete the test below.</li></ol> </li> Create the test VBScript file: <ol style="list-style-type: lower-alpha;"> Using Windows Notepad or another text editor, create a new text file.</li>  Paste the following code into the new text file: dim saxReader Set saxReader = CreateObject(&quot;Msxml2.SAXXMLReader.3.0&quot;) saxReader.putFeature &quot;server-http-request&quot;, true saxReader.parseURL &quot;http://localhost/big.xml&quot; WScript.Echo &quot;Done! saxReader.parseURL&quot; </li> Save the text file as C:\Big.VBS.</li></ol> </li> Open Windows NT Performance Monitor to monitor memory usage: <ol style="list-style-type: lower-alpha;"> In Microsoft Windows NT or Microsoft Windows 2000, press the CTRL+ALT+DEL keypad combination.</li> On the dialog box that is displayed, select Task Manager.</li> In Task Manager, click the Performance tab, and note the graph of Memory Usage History.</li> Size and position Performance Monitor so that you can see the Memory Usage History but still work on the Windows Desktop.</li></ol> </li> Test: <ol style="list-style-type: lower-alpha;"> On the Windows Start menu, select Run.</li>  In the Run dialog box, type the following command: wscript c:\big.vbs </li> Click OK, and note memory usage in Performance Monitor.</li></ol> </li></ol>

Keywords: kbbug kbprb KB291844

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.