469,270 Members | 1,231 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

ODBC Memory Leak

We are using ODBC connection pooling with SQL Server 2000 v5 on Win 2000 v5
sp4.

Each time we get a connection, SQLConnect, we see the memory usage go
up, about 52K. When we return the connection to the pool,
SQLDisconnect, and after the time that the connection remains in pool
expires we see the memory usage drop by about 28K.

Our basic steps for a select are:
SQLAllocHandle(SQL_HANDLE_DBC, hGblEnv, &hdbc);
SQLSetConnectAttr(hdbc, SQL_ATTR_LOGIN_TIMEOUT,
(SQLPOINTER)lLoginTimeOut, 0);
SQLSetConnectAttr(hdbc, SQL_ATTR_ACCESS_MODE,
(SQLPOINTER)SQL_MODE_READ_ONLY, SQL_IS_POINTER);
SQLConnect(hdbc,(SQLCHAR *)szDatabase, SQL_NTS,
(SQLCHAR *)szUserId, SQL_NTS,
(SQLCHAR *)szPassword, SQL_NTS);
SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
// Build the select statement
SQLExecDirect(hstmt, (SQLCHAR * )pszSQLStmt, strlen(pszSQLStmt));
SQLFetch(hstmt);
SQLFreeHandle (SQL_HANDLE_STMT, hstmt);
SQLDisconnect(hdbc);

Same memory leak occurs in DB2, but that's another forum.
Jul 20 '05 #1
1 6293
[posted and mailed, please reply in news]

M. Oakley (mo*****@acrosoft.com) writes:
We are using ODBC connection pooling with SQL Server 2000 v5 on Win 2000
v5 sp4.

Each time we get a connection, SQLConnect, we see the memory usage go
up, about 52K. When we return the connection to the pool,
SQLDisconnect, and after the time that the connection remains in pool
expires we see the memory usage drop by about 28K.

Our basic steps for a select are:
SQLAllocHandle(SQL_HANDLE_DBC, hGblEnv, &hdbc);
SQLSetConnectAttr(hdbc, SQL_ATTR_LOGIN_TIMEOUT,
(SQLPOINTER)lLoginTimeOut, 0);
SQLSetConnectAttr(hdbc, SQL_ATTR_ACCESS_MODE,
(SQLPOINTER)SQL_MODE_READ_ONLY, SQL_IS_POINTER);
SQLConnect(hdbc,(SQLCHAR *)szDatabase, SQL_NTS,
(SQLCHAR *)szUserId, SQL_NTS,
(SQLCHAR *)szPassword, SQL_NTS);
SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
// Build the select statement
SQLExecDirect(hstmt, (SQLCHAR * )pszSQLStmt, strlen(pszSQLStmt));
SQLFetch(hstmt);
SQLFreeHandle (SQL_HANDLE_STMT, hstmt);
SQLDisconnect(hdbc);


There is a known issue with a memory leak in ODBC, described in
http://support.microsoft.com/?id=814410. This fix is included in SP3a,
but *not* in SP3, so you might want to investigate if this could be
the same.

However, I'm not completely sure that this is the same leak. I did get
a repro for the original leak, which lead to the fix in 814410, but not
programming ODBC much myself, I don't remember the details.

In any case, in case SP3a does not resolve the problem, could you compose
a complete repro that demonstrates the problem? That is a program that
I can compile and run? In such case, I should be able to bring it up
with Microsoft.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by M. Oakley | last post: by
8 posts views Thread by ranjeet.gupta | last post: by
17 posts views Thread by Josť Joye | last post: by
4 posts views Thread by Don Nell | last post: by
20 posts views Thread by jeevankodali | last post: by
23 posts views Thread by James | last post: by
3 posts views Thread by Jim Land | last post: by
22 posts views Thread by Peter | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.