Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Marshaling ADO Recordset Out-of-Process Causes Small Memory Leak


View products that this article applies to.

This article was previously published under Q230487

↑ Back to the top


Symptoms

When an ADO recordset is marshaled out-of-process from a COM server, a small leak in Private Bytes occurs in the COM server's process space.

This leak occurs when using either a disconnected ADO recordset or a recordset created with the RDS DataFactory if you are using versions of MDAC earlier than 2.1 sp2.

↑ Back to the top


Cause

The leak is caused by ADO internally making an incorrect call to AddRef() on a Stream pointer within MarshalInterface.

↑ Back to the top


Status

This problem has been fixed in Microsoft Data Access Components 2.1 and later. You may download the latest version of Microsoft Data Access Components from the following site:

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Create an Executable project in Visual Basic that will be the server application. Name the project LeakEXE, and within it, create a class module named LeakRS. Set a reference to the Microsoft ActiveX Data Objects Library. Use the following code within the LeakRS class:
    Option Explicit
    
    Function GetRS() As ADODB.Recordset
    Dim rs As ADODB.Recordset
        
        On Error Resume Next
        Set rs = New ADODB.Recordset
        rs.Fields.Append "x", adInteger
        rs.Open
        rs.AddNew
        rs.Fields(0).Value = 1
        rs.Update
        rs.MoveFirst
        Set GetRS = rs
        
    End Function
    					
  2. Next, create a client project in Visual Basic, using the following code. Then, set a reference to the ActiveX EXE and to Microsoft ActiveX Data Objects Library.
    
    Sub OutofProcLeak()
    Dim x As New LeakEXE.LeakRS
    Dim rs As ADODB.Recordset
    
    For i = 0 To 200000
        Set rs = x.GetRS
        Debug.Print Str(i)
        DoEvents
    Next
    
    Set rs = Nothing
    					
  3. Run the client application. Use the Windows NT Performance Monitor to watch Private Bytes counter for object Process using instance LeakEXE.exe.

↑ Back to the top


Keywords: kbhotfixserver, kbado210fix, kbbug, kbdatabase, kbfix, kbmdac210fix, kbmdacnosweep, kbqfe, KB230487

↑ Back to the top

Article Info
Article ID : 230487
Revision : 9
Created on : 5/17/2007
Published on : 5/17/2007
Exists online : False
Views : 513