FIX: Repeated Load and Unload of Mtxdm.dll Causes 1MB Virtual Memory Leak
ID: Q232351
|
The information in this article applies to:
-
Microsoft Data Access Components version 2.1 (GA)
-
Microsoft Transaction Server 2.0
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://www.microsoft.com/support/supportnet/overview/overview.asp
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed
at the beginning of this article. This problem was first corrected in Windows NT 4.0 Service Pack 6.
Manual Installation
- 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.
- Download the hotfix (051099a.exe) into a temporary directory and run it to extract the following files:
- 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.
- 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 : kbMTS200fix kbSDKODBC351fix kbWinDNA kbGrpSIE NT4SP6Fix kbDSupport kbVirtualMem kbMDAC210fix
Version : WINDOWS:2.1 (GA); winnt:2.0
Platform : WINDOWS winnt
Issue type : kbbug