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



The information in this article applies to:

  • Microsoft XML 4.0
  • Microsoft XML 3.0
  • Microsoft XML 2.6
  • Microsoft XML 2.5
  • Microsoft XML 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, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may 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 immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

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 "Applies to" 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

  1. Start Visual Basic 6.0.
  2. 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.
  3. 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 & "\xml\VBLeaks.xml") = False) Then
                Call Err.Raise(5, "Test", g_objTest.parseError.reason)
            End If
        End If
        Set Test = g_objTest.cloneNode(True)
    End Function
  4. On the Project menu, click References.
  5. In the References - Project1 dialog box, click Microsoft XML, v2.6 reference, and then click OK.
  6. On the File menu, click Make Project1.dll.
  7. Call the Test function in the Project1.dll file from a worker thread of a client application.

MORE INFORMATION

REFERENCES

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:

170946 How to create and use a minimal ActiveX component in VB

824684 Description of the standard terminology that is used to describe Microsoft software updates


Modification Type:MajorLast Reviewed:2/16/2006
Keywords:kbHotfixServer kbQFE kbDLL kbXML kbbug kbfix KB324399 kbAudDeveloper