FIX: Repeated Load and Unload of Mtxdm.dll Causes 1MB Virtual Memory Leak

Article translations Article translations
Article ID: 232351
This article was previously published under Q232351
Expand all | Collapse all

On This Page

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:
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:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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:
  • Windows Service Pack Center -or-

  • 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:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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);
	   }
   }
				

Properties

Article ID: 232351 - Last Review: August 2, 2012 - Revision: 7.0
Keywords: 
kbqfe kbhotfixserver kbbug kbfix kbmdac210fix kbmts200fix kbsdkodbc351fix kbvirtualmem KB232351

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com