Skip to Content.
Sympa Menu

freetds - [freetds] Memory Leaks during Connect

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: <manoranjan_sahu AT agilent.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Memory Leaks during Connect
  • Date: Thu, 31 Jul 2003 20:22:11 -0600


Hello,
I am getting about 150 bytes memory leak for each connection to the SQL
server. Here is a sample program and some stack trace from where the memory
was allocated. My guess is that the memory is not being freed during
SQLDisconnect.

I am using freetds0.61 with unixodbc2.2.5 to connect to SQL server 2000.

Please let me know if there is going to be fix for this bug.

Thanks,
Manoranjan


----------------------------------------------------------------------------
CUT HERE
----------------------------------------------------------------------

#include <stdlib.h>
#include <stdio.h>
#include </net/hydra/usr/local1/unixodbc/include/sql.h>
#include </net/hydra/usr/local1/unixodbc/include/sqlext.h>
#include </net/hydra/usr/local1/unixodbc/include/sqltypes.h>

SQLHENV V_OD_Env; // Handle ODBC environment
long V_OD_erg; // result of functions
SQLHDBC V_OD_hdbc; // Handle connection
SQLINTEGER V_OD_err;

int main(int argc,char *argv[])
{
// 1. allocate Environment handle and register version
V_OD_erg=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&V_OD_Env);
if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
{
printf("Error AllocHandle\n");
exit(0);
}
V_OD_erg=SQLSetEnvAttr(V_OD_Env, SQL_ATTR_ODBC_VERSION,
(void*)SQL_OV_ODBC3,
0);
if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
{
printf("Error SetEnv\n");
SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
exit(0);
}
// 2. allocate connection handle, set timeout
V_OD_erg = SQLAllocHandle(SQL_HANDLE_DBC, V_OD_Env, &V_OD_hdbc);
if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
{
printf("Error AllocHDB %d\n",V_OD_erg);
SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
exit(0);
}
SQLSetConnectAttr(V_OD_hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0);
// 3. Connect to the datasource "web"
V_OD_erg = SQLConnect(V_OD_hdbc, (SQLCHAR*) "QADATASOURCE", SQL_NTS,
(SQLCHAR*) "notqa", SQL_NTS,
(SQLCHAR*) "notqa", SQL_NTS);
if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
{
printf("Error SQLConnect %d\n",V_OD_erg);
SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
exit(0);
}
printf("Connected !\n");
SQLDisconnect(V_OD_hdbc);
SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
return(0);
}


----------------------------------------------------------------------------
CUT HERE
----------------------------------------------------------------------



MLK: 92 bytes leaked at 0x1f8a38
This memory was allocated from:
malloc [rtlib.o]
tds_alloc_login [mem.c:557]
_SQLAllocConnect [odbc.c:497]
SQLAllocHandle [odbc.c:472]
__connect_part_one [SQLConnect.c:1257]
SQLConnect [SQLConnect.c:3429]
main [odbc_unpure.o]
_start [crt1.o]
MLK: 18 bytes leaked at 0x1fe3a8
This memory was allocated from:
malloc [rtlib.o]
strdup [libc.so.1]
_SQLAllocEnv [odbc.c:543]
SQLAllocHandle [odbc.c:475]
__connect_part_one [SQLConnect.c:1089]
SQLConnect [SQLConnect.c:3429]
main [odbc_unpure.o]
_start [crt1.o]
MLK: 16 bytes leaked at 0x1fdc10
This memory was allocated from:
malloc [rtlib.o]
_SQLAllocEnv [odbc.c:524]
SQLAllocHandle [odbc.c:475]
__connect_part_one [SQLConnect.c:1089]
SQLConnect [SQLConnect.c:3429]
main [odbc_unpure.o]
_start [crt1.o]
MLK: 16 bytes leaked at 0x1fe1c8
This memory was allocated from:
malloc [rtlib.o]
tds_alloc_context [mem.c:462]
_SQLAllocEnv [odbc.c:530]
SQLAllocHandle [odbc.c:475]
__connect_part_one [SQLConnect.c:1089]
SQLConnect [SQLConnect.c:3429]
main [odbc_unpure.o]
_start [crt1.o]
MLK: 12 bytes leaked at 0x1fdff0
This memory was allocated from:
malloc [rtlib.o]
tds_alloc_locale [mem.c:481]
tds_get_locale [locale.c:60]
tds_alloc_context [mem.c:459]
_SQLAllocEnv [odbc.c:530]
SQLAllocHandle [odbc.c:475]
__connect_part_one [SQLConnect.c:1089]
SQLConnect [SQLConnect.c:3429]
main [odbc_unpure.o]
_start [crt1.o]




  • [freetds] Memory Leaks during Connect, manoranjan_sahu, 07/31/2003

Archive powered by MHonArc 2.6.24.

Top of Page