DB2-NT-ODBC-MFC CRecordset: Memory Leaks 
Author Message
 DB2-NT-ODBC-MFC CRecordset: Memory Leaks

We are porting an application from OS/2 using DB2 with embedded SQL over
to NT, and trying to use DB2 with ODBC calls  via MFC CDatabase and
CRecordset classes.  Was making good progress until I retrieved and
displayed ( in a dialog box) 32 records in a row, at which time a
messagebox popped up with an SQL error from DB2 stating that the
application had run out of heap space.  I used the NT Task manager to
see that we are indeed leaking memory, and used CMemoryState Checkpoint
function to narrow the leakage down to the CRecordset calls.  In reading
the Microsoft documentation, it states that if the CRecordset-derived
class variable is declared on the frame, it will be destroyed when the
function returns.  This was how I was doing it, but changed it to create
the CRecordset-derived class instance using new, and made sure I deleted
it before the function returns.   That did not work, either.  When I use
DumpObjects to see what's allocated, in addition to my active variables
I get the following (as an example):

{54} client block at 0x00441D50, 64 bytes long
a CDynLinkLibrary object at $00441E90, subtype 0, 64 bytes long.
(There is one of these "pairs"  for every CRecordset Open() call )

It seems as though that somewhere in the CRecordset Open() call, memory
is being allocated  that never gets freed.  Am I missing something?  Is
there a configuration issue I need to resolve?  Secret calls buried deep
in either the DB2 or MFC documentation?  Any help would be greatly

Sat, 12 Oct 2002 03:00:00 GMT
 [ 1 post ] 

 Relevant Pages 

1. Help! MFC ODBC memory leaks

2. ODBC NT Service and JET 4.0 : memory leaks

3. MFC Recordsets and memory leak

4. DAO MFC memory leak

5. Problems retrieving data from MS SQL through ODBC and CRecordset (MFC)

6. Possible ODBC Driver Bug (via VC++/MFC CRecordset)

7. MFC ODBC CRecordset: Select Distinct columns

8. Regarding simple database modifications using CRecordset (MFC) and ODBC

9. ODBC / MFC / CRecordset Problem


Powered by phpBB® Forum Software