This article was previously published under Q283106
This article has been archived. It is offered "as is" and will no longer be updated.
If a Visual C++ application or dynamic-link library (DLL) aggregates ActiveX Data Objects (ADO) Recordset or Command objects, a significant memory leak can occur due to resources that are not freed when the Release function is called on the object.
This occurs in all versions of ADO prior to and including version 2.6 RTM (2.60.6526).
Aggregation in Recordset and Command objects is implemented by using the CComAggObject classes in Active Template Library (ATL). CComAggObject deletes itself when its reference count goes to zero, and simply deletes the Recordset or Command object as well. The Recordset or Command object's Term function is never called, which is where the clean-up of allocated resources occurs.
To resolve this problem, obtain the latest service pack for Microsoft MDAC 2.5. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
293312INFO: How to Obtain the Latest MDAC 2.5 Service Pack
This problem was corrected in Microsoft Data Access Components 2.6 Service Pack 1. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack
The English version of this fix should have the following file attributes or later:
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft MDAC 2.5 Service Pack 3. This problem was first corrected in Microsoft Data Access Components 2.6 Service Pack 1.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
This behavior is likely to be seen only when the application has been written in Visual C++, and when the developer deliberately aggregates Recordset or Command objects. This behavior does not occur in Microsoft Visual Basic applications, because aggregation is not possible from Visual Basic.
The MDAC 2.5 version of this hotfix can be applied over both 2.5 RTM (2.50.4403) and 2.5 SP1 (2.50.5303).
Steps to Reproduce Behavior
Paste the following code into a new Visual C++ console application, and then compile and run the code.