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

ID: Q243272


The information in this article applies to:
  • Microsoft OLE DB, version 2.0, used with:
    • Microsoft Visual C++, 32-bit Editions, version 6.0


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/>
   } 


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Additional query words:

Keywords : kbATL kbDatabase kbOLEDB kbVC kbVC600bug kbConsumer kbGrpVCDB kbDSupport
Version : WINDOWS:2.0
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: November 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.