Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Memory Leak in Microsoft Access ODBC Driver in MDAC 2.0

View products that this article applies to.

This article was previously published under Q195017

↑ Back to the top


The Microsoft Access ODBC Driver, version 3.51.1713, which is provided with the Microsoft Data Access Components version 2.0, leaks memory when opening a connection, performing a query on that connection, and then closing the connection.

↑ Back to the top


To work around this behavior, keep the connection open as long as possible. Minimizing the number of times you make a connection will minimize the memory leak.

↑ Back to the top


Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This bug was corrected in in a newer version of the Access ODBCDriver included with MDAC 2.1.

↑ Back to the top

More information

As an example, the following code causes several hundred bytes to leak for each iteration through the loop:
   for(int nLoops=0; nLoops < 1000; nLoops++)
     RETCODE rc;
     SQLAllocConnect(henv, &hdbc);

     SWORD nResult;
     UCHAR szConnectOutput[255];
     rc = SQLDriverConnect(hdbc, NULL,(UCHAR*)(const char*)"DSN=MYDSN",
                        SQL_NTS,szConnectOutput, 255, &nResult,

     SQLAllocStmt(hdbc, &hstmt);
     rc = SQLExecDirect(hstmt, (UCHAR *)"SELECT * from table1", SQL_NTS);


↑ Back to the top

Keywords: KB195017, kbjet, kbfix, kbdriver, kbdatabase, kbbug

↑ Back to the top

Article Info
Article ID : 195017
Revision : 3
Created on : 12/3/2003
Published on : 12/3/2003
Exists online : False
Views : 337