DOCUMENT:Q132494 12-JUN-2001 [odbc] TITLE :PRB: Memory Leaks in SQL Srv Driver During Connect/Disconnect PRODUCT :Open Database Connectivity (ODBC) PROD/VER:WINDOWS:2.0,2.5 OPER/SYS: KEYWORDS: ====================================================================== 2.00.1912 2.50.0121 WINDOWS kbprb kbprg ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Open Database Connectivity, versions 2.0, 2.5 ------------------------------------------------------------------------------- SYMPTOMS ======== The following sequence of calls: SQLAllocEnv, SQLAllocConnect, SQLConnect (or SQLDriverConnect), SQLDisconnect, SQLFreeConnect, and SQLFreeEnv can lead to a 4K memory leak in the following Microsoft SQL Server drivers: - 16-bit SQL Server Driver 2.00.1912, ships with SQL Server version 4.21a - 32-bit SQL Server Driver 2.00.1912, ships with SQL Server version 4.21a - 16-bit SQL Server Driver 2.50.0121, ships with SQL Server version 6.0 CAUSE ===== STEPS TO CHECK 32-BIT SQL SERVER DRIVER MEMORY LEAKS: Start the Process Viewer in the NT Resource Kit. Start the 32-bit ODBC Test application. 1. Inside P-Viewer, select ODBCTE32, click Refresh, and write down the number of "Heap Usage." 2. Inside 32-bit ODBC Test: a. From the Connect menu, select SQLAllocEnv. b. From the Connect menu, select SQLAllocConnect. c. From the Connect menu, select SQLConnect and connect to SQL Server data source. Alternatively, you can select SQLDriverConnect instead of SQLConnect. d. From the Connect menu, select SQLDisconnect, SQLFreeConnect, and SQLFreeEnv. 3. Go back to P-Viewer, click Refresh, again write down the number of "Heap Usage." Process Viewer will show 4K memory leaks in the SQL Server Drivers mentioned above. Every time you repeat steps 2.a through 2.d, another 4K of memory stays allocated. NOTE: There is no memory leakage in the 32-bit SQL Server driver 2.50.0121 that ships with SQL Server version 6.0. WORKAROUND ========== Share ODBC connections as much as possible in the application. Additional query words: 2.00.1912 2.50.0121 sql6 6.00 4.21a ====================================================================== Keywords : Technology : kbAudDeveloper kbODBCSearch kbODBC200 kbODBC250 Version : WINDOWS:2.0,2.5 ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.