Memory leak in ADODB Connection15::Open method



We have a client server application using ASP, ATL COM and SqlServer. We have
found 36 bytes of memory leak in Connection15::Open method when we ran
Rational Purify and we have no idea why it is happening. Here is the example
code.

"dbbase.cpp"
------------------
void CDBBase::CreateDBHandle (CDBBase& pObj, bool bReadonly)
{
CreateDBHandle (bReadonly);
pObj.CopyDBHandle (this);
}

void CDBBase::CopyDBHandle (CDBBase* pObj)
{
m_pConn = pObj->m_pConn;
m_bDBHandleCreated = false;
}

void CDBBase::CreateDBHandle (bool bReadonly)
{
if (m_pConn == NULL)
{
m_pConn.CreateInstance (AdoGuids.m_Connection);

if (g_CommandTimeout == -1)
InitQueryTimeout();

m_pConn->CommandTimeout = g_CommandTimeout;

m_pConn->Open (
m_bstrLogonString,
bstrEmpty,
bstrEmpty,
ADODB::adConnectUnspecified );

m_bDBHandleCreated = true;
}
}


"msado15.tli"
-------------
inline HRESULT Connection15::Open ( _bstr_t ConnectionString, _bstr_t
UserID, _bstr_t Password, long Options ) {
HRESULT _hr = raw_Open(ConnectionString, UserID, Password, Options);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr;
}

Purify is showing a memory leak of 36 bytes in Connection15::Open method
above.

[W] MLK: Memory leak of 36 bytes from 1 block allocated in
ADODB::Connection15::Open(_bstr_t,_bstr_t,_bstr_t,long)
[ImplementationLibrary.dll]
Distribution of leaked blocks
Allocation location
LocalAlloc [C:\WINNT\system32\KERNEL32.DLL]
ADODB::Connection15::Open(_bstr_t,_bstr_t,_bstr_t,long)
[o:\applogic\interm\debug\supportlibrary\msado15.tli:1229]
}

inline HRESULT Connection15::Open ( _bstr_t
ConnectionString, _bstr_t UserID, _bstr_t Password, long Options ) {
=> HRESULT _hr = raw_Open(ConnectionString, UserID,
Password, Options);
if (FAILED(_hr)) _com_issue_errorex(_hr, this,
__uuidof(this));
return _hr;
}

CDBBase::CreateDBHandle(bool)
[d:\broker\common\develop\supportlibrary\dbbase.cpp:121]
m_bstrLogonString,
bstrEmpty,
bstrEmpty,
=> ADODB::adConnectUnspecified );

//m_pConn->PutCursorLocation(ADODB::adUseClient);
// NOTE: Above line is necessary for fetching
resultsets and output parameters.

CDBBase::CreateDBHandle(CDBBase&,bool)
[d:\broker\common\develop\supportlibrary\dbbase.cpp:150]
EXTLOG ("CreateDBHandle(): creating and copying DB
handle");
#endif

=> CreateDBHandle (bReadonly);
pObj.CopyDBHandle (this);
}

We are using MDAC version 2.81, Visual C++ .NET, Microsoft Development
Environment 2003 and Microsoft .NET Framework 1.1

Any help regarding the memory leak fix would be greatly appreciated.

Thanks,
-amar
.



Relevant Pages

  • Re: Memory leak
    ... > void f ... There is no pointer pointing to it anymore, ... means you have no way of freeing it again: you created a memory leak. ... So the correct sequence in your example would be: ...
    (comp.lang.cpp)
  • Re: C++ is slow
    ... >> void main ... > If you use anything else besides 'int' return type ... > You have a memory leak. ... >> PROG II ...
    (comp.lang.cpp)
  • Re: obj function hello()
    ... gert wrote: ... Can you collaborated on the memory leak part please? ... void leak(size_t howmuch) { ...
    (comp.lang.c)
  • memory leak?
    ... I get memory leak ... report, but really have no idea what is wrong. ... #define CLEAR_CRT_DEBUG_FIELD((void) 0) ...
    (microsoft.public.vc.stl)
  • RE: copied music cds have a skip in last 18 seconds
    ... If installing all missing Windows Updates doesn't fix your problem ... xiowan.......in tucson ...
    (microsoft.public.windows.mediacenter)