Microsoft KB Archive/151663

= PRB: Memory Leak in MFC Using ODBC Oracle Driver on Win 95 =

Article ID: 151663

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription 

-



This article was previously published under Q151663



SYMPTOMS
An MFC ODBC application dynamically linked to an MFC DLL and connecting to an Oracle data source from a Windows 95 machine using the Intersolve 32-bit ODBC driver for Oracle, may display the following error messages in the output window of the debugger (with MFC tracing enabled) when exiting:

  The thread 0xFFFB9919 has exited with code -1 (0xFFFFFFFF). Detected memory leaks! Dumping objects -> {203} normal block at 0x00650D10, 512 bytes long. Data: <              > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD   Object dump complete.

Object addresses and thread ID may be different. The same error messages may also appear when using DAO to access a linked table via an ODBC driver in an Oracle data source.



CAUSE
When the application connects to the data source, a thread is created that terminates when the application terminates. This causes DllMain in the MFC DLL to be called with DLL_PROCESS_DETACH from the secondary thread and causes the memory detection code to be executed before the memory is actually freed.

<div class="resolution_section">

RESOLUTION
The error message refers to memory that is actually being freed, not a memory leak. The message can be safely ignored. This can be verified by setting a breakpoint in _AFX_THREAD_STATE destructor (AFXSTATE.CPP) and stepping through the code. In one of the cases, you should see that the following line is executed for the memory at the address that is supposed to be leaking: free(m_pSafetyPoolBuffer);

<div class="status_section">

STATUS
This behavior is by design. However, the design was changed in Visual C++ version 4.2, so this is no longer a problem.

<div class="moreinformation_section">

MORE INFORMATION
To reproduce the problem, set up an Oracle data source on a Windows 95 machine with an Intersolve 32-bit ODBC driver and the proper SQL*Net components. Generate a default ODBC application ( SDI, "Database support, no file support" ). Add the following code to the InitInstance function: CDatabase db; db.Open(NULL); // select 32-bit Oracle data source at run-time db.Close; return FALSE;

/* Compile options needed: Standard */ Using the Visigenic 32-bit ODBC driver for Oracle produces similar error messages, but Visigenic currently does not support their driver on Windows 95. For more information on that issue, please refer to the following article in the Microsoft Knowledge Base:

140498 INF: Using the Visigenic Oracle Driver on WinNT & Win95

Additional query words: 4.00 4.10

Keywords: kbdatabase kberrmsg kbprb KB151663

-

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

© Microsoft Corporation. All rights reserved.