BUG: Memory Leak in Desktop Database Drivers
PSS ID Number: Q105797 Article last modified on 11-24-1993
1.01.1928 WINDOWS
The information in this article applies to: |
- Microsoft Open Data Base Connectivity version 1.0 |
BUG# ODBCDBASE: 1850 (1.01.1928)
SYMPTOMS
The ODBC Desktop Database Drivers have a memory leak due to which, a memory allocation error occurs when a program repeatedly allocates and frees a statement handle with the SQL_CLOSE option. Allocating and freeing a statement handle (with fOption = SQL_CLOSE) repeatedly will cause a memory allocation error in the 248th iteration. This problem exists in all the drivers shipping with the ODBC Desktop Database Drivers (dBASE, FoxPro, Paradox, BTRIEVE, Access, Excel and Text). The following code fragment illustrates the problem: SQLAllocEnv(&henv); SQLAllocConnect (henv, &hdbc); SQLDriverConnect (hdbc, hwnd, "", 0, szConnStrOut, MAX_CONN_STR_SIZE, &cbConnStrOut, SQL_DRIVER_PROMPT); for (i=1; i<500; i++) { SQLAllocStmt(hdbc, &hstmt); SQLFreeStmt (hstmt, SQL_CLOSE); } In the 248th iteration through the for loop, the following memory allocation error occurs: SQLAllocStmt returned SQL_ERROR SQLSTATE = S1001, pfNativeError = [Microsoft][ODBC Single-Tier Driver]Memory allocation error
WORKAROUND
Use the following statement: fOption = SQL_DROP instead of using the following in the SQLFreeStmt command: fOption = SQL_CLOSE
STATUS
Microsoft has confirmed this to be a problem in the ODBC Desktop Database Drivers version 1.01.1928. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
Additional reference words: 1.01.1928 ODBC
Copyright Microsoft Corporation 1993.