3 messages in com.mysql.lists.bugsMemory leak in SQLConnect/Disconnect?
FromSent OnAttachments
Monika André-Jönsson09 Jul 2001 14:40 
Timothy Smith09 Jul 2001 16:58 
Venu Anuganti11 Jul 2001 08:44 
Subject:Memory leak in SQLConnect/Disconnect?
From:Monika André-Jönsson (moni@factum.se)
Date:07/09/2001 02:40:00 PM
List:com.mysql.lists.bugs

Hello,

I use MyODBC in my Win32 application to communicate with my MySQL database. Works fine for retrieving and inserting data, but when we checked the memory for connections to the MySQL database via MyODBC, it leaks about 1K per connection (after disconnection). We do lots of connections over a period of time and finally this adds up.

This is how I do: 1. nEnvRes = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_hDBEnv);

2. SQLSetEnvAttr(m_hDBEnv,200,(SQLPOINTER) SQL_OV_ODBC3,SQL_IS_INTEGER);

3. nConnHandleRes = SQLAllocHandle(SQL_HANDLE_DBC, m_hDBEnv, &m_hDBCon);

(This don't leak memory and returns 0 like in SQL_SUCCESS) 4. nConnRes = SQLConnect(m_hDBCon, (SQLCHAR *)sDSN.c_str(),sDSN.size(), (SQLCHAR *)user.c_str(),user.size(), (SQLCHAR *)pass.c_str(), pass.size()); (This does leak memory, and returns SQL_SUCCESS_WITH_INFO, the info text is: "[Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr)") 5. Close and frees the handles after using them. if (m_hDBCon != SQL_NULL_HANDLE) { SQLDisconnect(m_hDBCon); SQLFreeHandle(SQL_HANDLE_DBC, m_hDBCon); m_hDBCon = SQL_NULL_HANDLE; } if (m_hDBEnv != SQL_NULL_HANDLE) { SQLFreeHandle(SQL_HANDLE_ENV, m_hDBEnv); m_hDBEnv = SQL_NULL_HANDLE; }

I use ODBC version: 3.520.4403.2 MyODBC version: 2.50.33.00 MySQL version: 3.23.32

Does anyone know anything about this? Is it SQLDisconnect that doesn't free the handles as it should? Is it an ODBC or a MyODBC problem?

Thanx, /Monika A-J