Memory leaks are reported when you use multiple MFC DLLs (167929)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q167929 SYMPTOMS
When you debug a project that contains MFC regular (USRDLL) DLLs or ActiveX
Controls (OCX), you may see memory leaks similar to the following reported
in the debugger:
a CDynLinkLibrary object at $00410F70, 64 bytes long
a CDynLinkLibrary object at $00410F70, 64 bytes long
{38} client block at 0x00410D80, subtype 0, 64 bytes long.
a CDynLinkLibrary object at $00410D80, 64 bytes long
a CDynLinkLibrary object at $00410D80, 64 bytes long
{36} client block at 0x00410C60, subtype 0, 64 bytes long.
a CDynLinkLibrary object at $00410C60, 64 bytes long
a CDynLinkLibrary object at $00410C60, 64 bytes long
CAUSE
These memory leaks are reported when multiple versions of the MFC DLL are
loaded in the same process. Since MFC extension (AFXDLL) DLLs require the
exact same MFC DLL as the call application, this problem can only occur
when using MFC regular (USRDLL) DLLs or ActiveX Controls (OCX) that use the
shared version of MFC.
The most common case is mixing ANSI (MFC4xd.DLL) and UNICODE (MFC4xxUd.DLL)
versions of MFC in the same process. This can also occur when mixing
MFC42d.DLL and MFC40d.DLL.
RESOLUTION
These memory leak notifications are false, and can be ignored. Since
neither copy of MFC knows about the other ones, it's not easy to stop these
false leaks from being reported. However, it is possible to separate the
false leaks from the potential real leaks. This can be done by overriding
CWinApp::ExitInstance() in both the EXE and DLL and placing TRACE()
statements in them:
int CTestDllApp::ExitInstance()
{
TRACE(_T("ExitInstance() for regular DLL: TESTDLL\n"));
return CWinApp::ExitInstance();
}
Only the memory leaks that are detected after the last
CWinApp::ExitInstance() is called are true memory leaks.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 6/6/2005 |
---|
Keywords: | kbtshoot kbDLL kbprb KB167929 kbAudDeveloper |
---|
|