Microsoft KB Archive/324399

= FIX: Memory leak may occur when a worker thread from a client calls a Visual Basic ActiveX DLL =

Article ID: 324399

Article Last Modified on 11/15/2007

-

APPLIES TO


 * Microsoft XML Core Services 4.0
 * Microsoft XML Parser 3.0
 * Microsoft XML Parser 2.6
 * Microsoft XML Parser 2.5
 * Microsoft XML Parser 2.0

-



This article was previously published under Q324399





SYMPTOMS
A Microsoft Visual Basic ActiveX DLL has an apartment-threaded thread, has the Unattended Execution property set and the Retained In Memory property set, and contains a global XML DomDocument object. If the Visual Basic ActiveX DLL has a simple function that is named Test that returns a clone of this global XML DomDocument object, a memory handle leak or thread handle leak may occur when the Test function is called from a worker thread of a client application.



RESOLUTION
A supported hotfix is now available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft XML 3.0 service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.  Date         Time    Version     Size       File name     Platform 14-Jun-2002 06:38  8.20.9814.0   1,120,768  msxml3.dll      x86



WORKAROUND
To work around this problem, use one of the following methods:
 * Remove the global reference of the XML DomDocument object from the Visual Basic ActiveX DLL.
 * Use Microsoft Visual C++ to create the ActiveX DLL instead of using Visual Basic to create a ActiveX DLL. There is no memory leak with a Visual C++ ActiveX DLL.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.This problem is fixed in MSXML 3.0 Service Pack 3 (SP3).



MORE INFORMATION
This hotfix is also available in MSXML 3.0 Service Pack 3 (SP3). MSXML 3.0 SP3 is included with Microsoft Internet Explorer 6.01 and with Microsoft Windows XP SP1. This hotfix is not available as a separate Web release.

Steps to reproduce the behavior
 Start Visual Basic 6.0. On the New tab in the New Project dialog box, click ActiveX DLL, and then click Open.

Note By default the Class1.cls file is created.  Add the following code to the Class1.cls file: Option Explicit Public g_objTest As MSXML2.DOMDocument

Public Function Test As MSXML2.DOMDocument If (g_objTest Is Nothing) Then Set g_objTest = New MSXML2.DOMDocument If (g_objTest.Load(App.Path & &quot;\xml\VBLeaks.xml&quot;) = False) Then Call Err.Raise(5, &quot;Test&quot;, g_objTest.parseError.reason) End If   End If    Set Test = g_objTest.cloneNode(True) End Function  On the Project menu, click References.</li> In the References - Project1 dialog box, click Microsoft XML, v2.6 reference, and then click OK.</li> On the File menu, click Make Project1.dll.</li> Call the Test function in the Project1.dll file from a worker thread of a client application.</li></ol>

<div class="moreinformation_section">

MORE INFORMATION
<div class="references_section">