Microsoft KB Archive/243272

= FIX: Memory Leak While Using the OLE DB ATL Consumer CBulkRowset Class =

Article ID: 243272

Article Last Modified on 10/15/2002

-

APPLIES TO

 Microsoft OLE DB 2.7, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q243272

<div class="symptoms_section">

SYMPTOMS
When using the Visual C++ OLE DB consumer template classes and using the CBulkRowset class with the CTable or CCommand class, memory will leak if Open and Close are called multiple times without destructing the CTable or CCommand object.

The exact amount of memory leaked will vary based on the number of rows specified in the call to CBulkRowset::SetRows.

<div class="cause_section">

CAUSE
In Atldbcli.h there is a data member of CBulkRowset called m_phRow that points to an array of row handles. The CBulkRowset:BindFinished method of the class allocates storage for a new set of row handles and assigns the allocation to m_phRow. The array is then deleted in the class destructor.

This method works as long as the rowset is only opened and closed once. However, if you Open and Close the CBulkRowset object repeatedly without destructing the object, the second and all subsequent times through BindFinished will set the m_phRow data member to NULL, without freeing the previously allocated member.

<div class="resolution_section">

RESOLUTION
The resolution is to add code to free the memory immediately after calling Close. For example: rs.Close; if(rs.m_phRow != NULL) {  delete [] rs.m_phRow; rs.m_phRow = NULL;<BR/> }

<div class="status_section">

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

This problem was corrected in Microsoft Visual C++ .NET.

Keywords: kbbug kbfix kbnoupdate kbconsumer kbdatabase kbdtl kbmdacnosweep KB243272

-

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

© Microsoft Corporation. All rights reserved.