Memory Leak with Recordset?
- From: jalway@xxxxxxxxx
- Date: 15 Oct 2005 18:18:11 -0700
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
.
- Follow-Ups:
- Re: Memory Leak with Recordset?
- From: Stephen Howe
- Re: Memory Leak with Recordset?
- Prev by Date: Re: Discussing 3 different strategies for deleting from multiple tables
- Next by Date: Store procedure
- Previous by thread: Creating Access MDB's with ADOX.
- Next by thread: Re: Memory Leak with Recordset?
- Index(es):
Relevant Pages
|
Loading