Memory Leak with Recordset?



Hello,

I'm using ADO 2.5 with VC++ trying to release a recordset object from
memory, however the memory allocated when the recordset was populated
is not completely freed. Most of it, in fact, remains in memory.

I've read elsewhere (in this ng, post from Feb 1, 1999) that RecordSet
fields are AddRef'd but not Released, so that the reference count is
not decremented. A bug in ADO, apparently.

Even if I close the database connection and delete the class that holds
the smart pointers for ADO, and call CoUninitialize(), the memory is
not released until the app is exited.

Interestingly, the memory usage doesn't get any bigger, but it still
takes a large chunk of memory.

Here is the key code...

string getTableCount(string tableName,long& count)
{
_RecordsetPtr pRS;
count = 0l;
char bNum[20];
string strNum;

pRS.CreateInstance (__uuidof (Recordset));
pRS->CursorLocation = adUseClient;
pRS->CursorType = adOpenKeyset;
pRS->LockType = adLockOptimistic;
pRS->Open (tableName.c_str(),_variant_t((IDispatch*)m_pConn,true),
adOpenKeyset,adLockOptimistic,adCmdTable);

count = pRS->RecordCount;
sprintf(bNum,"%ld",count);
strNum = bNum;
pRS->Close();
pRS.Release();
pRS = NULL;
return strNum;
}


How can I solve this problem?

Thanks for any feedback.


...John

.



Relevant Pages

  • Re: Tips on finding memory leaks
    ... But when Access reports that it's using 500M of memory, ... The problem is that at least with Access as the front-end, and ADO in the ... mentioned collections and child objects along with ADO. ... what a Recordset is: "A collection of collections contains objects". ...
    (microsoft.public.vb.general.discussion)
  • Re: Recordset.AddNew and the recordset objects data retaining
    ... via an ADO recordset, then I'd strongly suggest you redesign your solution. ... > to do with the updates being in a transaction but rather on whether you specify ... > spill over and the memory starts paging out to disk that concerns me). ...
    (microsoft.public.data.ado)
  • Re: filter with vb code
    ... I guess ADO classic doesn't interest them. ... There may be no recordset in your post be there certainly is a memory ... SQL involving an open workbook causes a memory leak. ...
    (microsoft.public.excel.programming)
  • Re: Tips on finding memory leaks
    ... Any suggestions, either specific to ADO, collections, or just general to ... As for tracing memory leaks with VB, ... mentioned collections and child objects along with ADO. ... Recordset which can then be wrapped with an object to provide the same ...
    (microsoft.public.vb.general.discussion)
  • Re: ADO - permanent memory leak?!
    ... I have a memory leak in an application that makes repeated ... I have ADO 2.7 ... I am using MemProof 9.5.0 to isolate the problem. ... These are the only "memory growth" items. ...
    (borland.public.delphi.database.ado)

Loading