Microsoft KB Archive/232351

From BetaArchive Wiki

Article ID: 232351

Article Last Modified on 4/7/2006



APPLIES TO

  • Microsoft Windows NT 4.0
  • Microsoft Data Access Components 2.1 Service Pack 2



This article was previously published under Q232351

SYMPTOMS

When loading and unloading Mtxdm.dll within a loop, a 1MB leak in virtual memory is seen with every iteration through the loop.

This is most likely to occur in applications that are using an ODBC connection pooling and are making repeated connections and disconnections from the backend database, or ODBC applications that make many connections and disconnections to an Oracle backend.

CAUSE

The leak in virtual memory is being caused by a call to TerminateThread() within Mtxdm.dll.

When connection pooling is used within an ODBC application, the Dispenser Manager (Mtxdm.dll) is loaded to manage the connection pool, which is handled by a worker thread that is started within Mtxdm.dll.

When the application ends, the worker thread is killed by a call to TerminateThread(), which will not clean up and free the 1MB of memory allocated for the worker thread's stack.

This same behavior can be seen when making repeated connections and disconnections to an Oracle database server, because the Microsoft Oracle ODBC driver loads Mtxdm.dll whether connection pooling is being used or not.

RESOLUTION

To resolve this problem, obtain the latest service pack for Windows NT 4.0 or the individual software update. For information on obtaining the latest service pack, please go to:


  • 152734how to obtain the latest windows nt 4.0 service pack

For information on obtaining the individual software update, contact Microsoft Product Support Services. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:


Windows NT Server or Workstation 4.0

To resolve this problem, obtain the latest service pack for Windows NT 4.0 or the individual software update. For information on obtaining the latest service pack, please go to:


  • 152734how to obtain the latest windows nt 4.0 service pack

For information on obtaining the individual software update, contact Microsoft Product Support Services. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:


Windows NT Server 4.0, Terminal Server Edition

To resolve this problem, obtain the latest service pack for Windows NT Server 4.0, Terminal Server Edition. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

152734 How to Obtain the Latest Windows NT 4.0 Service Pack




STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Windows NT Server version 4.0, Terminal Server Edition Service Pack 6.

MORE INFORMATION

Manual Installation of Hotfix 051099a

NOTE: To obtain this hotfix, you must contact Microsoft Product Support Services. Please see the RESOLUTION section of this article for more information.

  1. Close or stop any applications or services that are using Mtxdm.dll. This may include Internet Information Server (IIS), Microsoft Transaction Server (MTS), Microsoft Distributed Transaction Coordinator (DTC), and any ADO or ODBC applications.
  2. Download the hotfix (051099a.exe) into a temporary directory and run it to extract the following files:
    • Mmtxdm.dll
    • Readme.txt
  3. Locate and rename the current version of Mtxdm.dll, which should be in the \Winnt\System32 folder for Windows NT computers, and in the \Windows\System folder for Windows 9x computers.
  4. Copy the hotfix version of Mtxdm.dll into the same location, and restart your services and applications.

Steps to Reproduce Behavior

Create a C/C++ console application using the following code. Run this application while using Performance Monitor to view Virtual Bytes for the application.

NOTE: This code sample uses an ODBC data source that connects to an Oracle backend, because the Microsoft Oracle ODBC driver loads Mtxdm.dll, and more easily demonstrates the problem.

   #include        <windows.h>
   #include        <stdio.h>
   #include        <sql.h>
   #include        <sqlext.h>
   #include        <assert.h>

   #define CK_RT(x) if( x != SQL_SUCCESS && x != SQL_SUCCESS_WITH_INFO)    assert(0)

   void main(){
       HENV        henv;
       HDBC        hdbc;
       RETCODE     rc = SQL_SUCCESS;
       char        *dsnStr="DSN=OracleServer;UID=scott;pwd=tiger;";
       short       rtnLen = 0;
       UCHAR       rtnDSN[999] = "";
       int         i,x;


       for (i=0; i < 100; i++)
    {
               rc = SQLAllocEnv(&henv);
               CK_RT(rc);
               rc = SQLAllocConnect(henv, &hdbc);
               CK_RT(rc);
               rc = SQLDriverConnect(hdbc,
                         NULL,
                         (unsigned char *)dsnStr,
                         strlen(dsnStr),
                         rtnDSN,
                         255,
                         &rtnLen,
                         SQL_DRIVER_NOPROMPT);

               CK_RT(rc);
               SQLDisconnect(hdbc);
               SQLFreeConnect(hdbc);
               SQLFreeEnv(henv);
       }
   }
                


Additional query words: virtual memory leak oracle mtxdm.dll odbc connection pooling exitprocess disconnect 1 MB 2320

Keywords: kbbug kbfix kbvirtualmem kbsdkodbc351fix kbqfe kbmts200fix kbmdac210fix kbhotfixserver KB232351