November 10, 2006 at 1:16 pm
It appears that there is a 4k memory leak and a 3 handle leak when using the following code.
// Allocate the environment handle
retCode = SQLAllocHandle(SQL_HANDLE_ENV,NULL, &henv);
if(retCode != SQL_ERROR && retCode != SQL_INVALID_HANDLE)
{
// Set the environment to ODBC Version 3.0
retCode = SQLSetEnvAttr(henv,
SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3,
SQL_IS_INTEGER);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
// Allocate a ODBC connection handle handle
retCode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLConnect( hdbc,
(UCHAR*)(LPCTSTR)strDSN,
SQL_NTS,
(UCHAR*)(LPCTSTR)strUID,
SQL_NTS,
(UCHAR*)(LPCTSTR)strPWD,
SQL_NTS);
if(retCode == SQL_SUCCESS_WITH_INFO)
{
GetErrorMsgs(hdbc, SQL_HANDLE_DBC, strDebugMsg);
OutputDebugString(strDebugMsg);
}
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
// So stuff with the connection
retCode = SQLDisconnect(hdbc);
}
else
{
GetErrorMsgs(hstmt1, SQL_HANDLE_STMT, strExceptionMsg);
}
}
retCode = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
}
else
{
GetErrorMsgs(hstmt1, SQL_HANDLE_STMT, strExceptionMsg);
}
}
else
{
GetErrorMsgs(hstmt1, SQL_HANDLE_STMT, strExceptionMsg);
}
retCode = SQLFreeHandle(SQL_HANDLE_ENV, henv);
...
The GetErrorMsgs function merely calls the SQLGetDiagRect function for the handle for which the error occurs and puts into the CString strExceptionMsg.
I hope I am not being too redundant with this problem, but is causing a big problem. Has there been a fix for this from Microsoft? I have searched the internet (Googled the problem) and not found a satisfactory answer.
The program was compiled using Visual Studio C++ 6.0 w/ SP1
The SQL Server driver version is 2000,85.1117.00.
The OS is Windows XP Pro with SP2.
Any help would be greatly appreciated.
Thanks!
Paul
Viewing post 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply