When you call the SQLBindParameter function in the Jet ODBC driver, and when you bind to a SQL data type of SQL_NUMERIC or when you bind SQL_C_BINARY to SQL_WCHAR, a memory leak occurs.
If you use the Performance Monitor (PerfMon) to watch the Private Bytes for the process, you see a gradual but steady memory increase, and the memory is not freed when the statements or connections close.
Buffers are used within the Jet ODBC driver to help convert the ODBC parameter data types to native data types for the Jet database engine. These buffers are referenced through pointers maintained on the statement handle, as part of the parameter descriptors (IPDs).
Normally, the code checks to see if the pointer already references a valid memory buffer, and then reuses the buffer if it exists. However, when binding a SQL_NUMERIC datatype, or when binding SQL_C_BINARY to SQL_WCHAR, new memory is allocated and assigned to the pointer without checking it first, and the previous value is overwritten.
How to Obtain the Latest Windows 2000 Service Pack
To resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.5. For additional information, click the following article number to view the article in the
Microsoft Knowledge Base:
INFO: How to Obtain the Latest MDAC 2.5 Service Pack
The English version of this fix should have the following file attributes or later:
Date Version Size File name
09/13/00 4.0.5708.0 270,608 bytes Odbcjt32.dll
09/14/00 126.96.36.199 295,696 bytes Q273772_W2K_SP2_x86_en.EXE
NOTE: This hotfix requires Microsoft Data Access Components (MDAC) 2.5 Service Pack 1 (SP1) or later because of dependencies on other files introduced with MDAC 2.5 SP1. There is no fix available that you can apply directly to MDAC 2.5.
To install this hotfix on a Microsoft Windows 2000 platform, run the hotfix installer package (Q273772_W2K_SP2_x86_en.EXE). Although the hotfix itself is not platform-dependent, the hotfix installer package is designed to run only on Windows 2000 platforms, and will not run on Microsoft Windows NT 4.0, Microsoft Windows 95 or Microsoft Windows 98 platforms. MDAC contains system file protected files and you can only replace those files by a digitally signed hotfix installer on Windows 2000. The standalone hotfix file is provided as well so that you can copy that file directly to Windows NT 4.0, Windows 95 or Windows 98 platforms.
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 Microsoft Data Access Components 2.5 Service Pack 2 and Microsoft Windows 2000 Service Pack 2.
If you examine the memory for the process periodically while the process runs, you see an increasing number of 0x100000 (1048576) byte allocations. If the process continues to run, the process eventually runs out of memory and stops responding (hangs) or fails.
Steps to Reproduce Behavior
Copy the code that follows into a Microsoft Visual C++ console application, and then compile the code. Please note that you may need to change the datasource name, user id and password.