Microsoft KB Archive/305676

= PRB: Memory Leak When MDAC Is Running on Windows NT 4.0 =

Article ID: 305676

Article Last Modified on 5/8/2003

-

APPLIES TO


 * Microsoft Data Access Components 2.6, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Data Access Components 2.6 Service Pack 1, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft Data Access Components 2.7, when used with:
 * Microsoft Windows NT 4.0
 * Microsoft ODBC Driver for Microsoft SQL Server 3.7

-



This article was previously published under Q305676



SYMPTOMS
When you use the ODBC Driver for SQL Server with MDAC 2.6 or later under Windows NT 4.0, you may notice a memory leak.



CAUSE
This problem occurs because Dbnetlib.dll does not stay in memory.



RESOLUTION
There are two ways to work around this problem:  Use the OLE DB provider for SQL Server. Make the following code changes:   Add the following application programming interface (API) declaration to a module in your project: Public Declare Function LoadLibrary Lib &quot;kernel32&quot; & _ Alias &quot;LoadLibraryA&quot; (ByVal lpLibFileName As String) As Long   Add the following code, which forces Dbnetlib.dll to stay in memory: Dim handle As Long Dim DLLName As String

' DBNETLIB.DLL should be located in the NT System directory.

DLLName = &quot;C:\WINNT\System32\DBNETLIB.DLL&quot; handle = LoadLibrary(DLLName)  

<div class="moreinformation_section">

Steps to Reproduce Behavior
 Create a system DSN named SQLTest that points to your SQL Server.</li> Create a new Standard EXE project in Visual Basic. Form1 is created by default.</li>  Add the following code to Form1: Private Sub Form_Load

Dim m_oConn As ADODB.Connection Dim counter As Long

'Dim handle As Long 'Dim DLLName As String

' DBNETLIB.DLL should be located in the NT System directory.

'DLLName = &quot;C:\WINNT\System32\DBNETLIB.DLL&quot; 'handle = LoadLibrary(DLLName)

While (1) counter = counter + 1 Set m_oConn = New ADODB.Connection m_oConn.Open &quot;DSN=SQLTest&quot; m_oConn.Close Set m_oConn = Nothing DoEvents Wend

End Sub </li> In Perfmon, add a counter that contains the following settings:

Performance object: Process

Select Counters from list: Private bytes

Select Instances from list: VB6

</li> Run the application, and observe the Perfmon counter.</li></ol>

Keywords: kbprb KB305676

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.