Re: Weird memory leak under XP (SP2)
On Fri, 18 Jan 2008 17:13:30 -0800 (PST), Jim <adirondackmtn@yahoo.com>
wrote:
Hi,
I finally upgraded my PC from win98 & now running XP SP2. I rebuilt
one of my many MFC apps (VC 6.0) and noticed memory leaks. I added a
return FALSE in InitInstance() of the main app, so there's no dialog
box and the leaks are still there:
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-
Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll',
no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic
information found.
Detected memory leaks!
Dumping objects ->
{45} normal block at 0x00322638, 33 bytes long.
Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD
CD
{44} normal block at 0x003225D0, 40 bytes long.
Data: < |L > 14 7C 4C 10 16 00 00 00 00 00 00 00 00 00 00
00
Object dump complete.
The thread 0xACC has exited with code 0 (0x0).
I noticed the odd double load of comctl32.dll. I created a dialog
based MFC app from scratch and that odd load isn't there. No leaks
either.
The comctl32.dll doesn't use the debug heap, so it isn't the reason for the
leak reports. I don't know why it appears to be loading twice. You can use
depends.exe to profile program startup in much greater detail than is
reported in the IDE output window.
Anyone know what gives and what I can do about it? Please don't tell
me to re-create my app. I have a bunch of 'em. :(
The low allocation numbers, their ordering, and those specific byte counts
indicate you're using the C++ Standard Library in a DLL, or some other
non-MFC DLL that uses this library. These leaks are spurious, and they're
due to MFC dumping leaks unnecessarily and prematurely when the MFC DLL is
unloaded, which causes false leaks to be reported for non-MFC DLLs that are
yet to be unloaded, which use the debug heap and deallocate memory in
static data destructors or atexit functions. See this message for the
workaround I use:
http://groups.google.com/group/microsoft.public.vc.language/msg/d8dbcb62d44bbe03
(I can't explain why you would see leaks in XP and not Win98, though.)
--
Doug Harrison
Visual C++ MVP