FIX: Memory Leak While Using the OLE DB ATL Consumer CBulkRowset Class (243272)
The information in this article applies to:
- Microsoft OLE DB, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q243272 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.
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.
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/>
}
STATUSMicrosoft 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.
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbBug kbConsumer kbDatabase kbDSupport kbDTL kbMDACNoSweep kbNoUpdate KB243272 |
---|
|