Using MFC CFileDIalog lead to memory Leak in windows 10

  • Thread starter Thread starter isugarhome
  • Start date Start date
I

isugarhome

Guest
i'm using visual studio 2005 in window 7, and create a mfc dialog demo, and i open a fileDialog On a buttion click response function. the code like this :

void CtestFileDialogDlg::OnBnClickedOk()
{
CFileDialog fileDlg(FALSE, L"dav", L"1234567890123456789012345678901234567890");
fileDlg.DoModal();
// TODO: 在此添加控件通知处理程序代码
//OnOK();
}


than i run it in windows 10 system, and click the button, then it can open a save dialog like this

open a save file dialog(sorry! i can't upload a image....)

and then i click the save button。 the dialog will close, then i repeat this progress all the day (open then close). private data of this program will increase from 10MB to 1.3GB。 i think the memory is leak. after that i using windbg to find the biggerst memory in the biggerst heap, like this :


0:004> !heap -stat -h 02d90000 -grp S
heap @ 02d90000
group-by: TOTSIZE max-display: 20
size #blocks total ( %) (percent of total busy bytes)
1b80 d4ef - 16dfac80 (48.29)
500 d4ef - 428ab00 (8.78)
20 14d5a9 - 29ab520 (5.50)
2a0 d4f0 - 22ef600 (4.61)
244 d4ef - 1e26d7c (3.98)
4c 4fdab - 17b4ec4 (3.13)
19c d4ec - 156abd0 (2.83)
138 d4f0 - 1038480 (2.14)
78 1a9df - c7a088 (1.65)
30 35484 - 9fd8c0 (1.32)
40 27f3c - 9fcf00 (1.32)
c0 d4fa - 9fbb80 (1.32)
24 429b5 - 95dd74 (1.24)
14 6a8c7 - 852f8c (1.10)
9c d4f4 - 81c4b0 (1.07)
94 d4eb - 7b17dc (1.02)
88 d4fd - 712668 (0.93)
2a 27ee8 - 68d210 (0.86)
28 27faf - 63f358 (0.82)
18 4296c - 63e220 (0.82)


then i chose one memory block which size is 1b80, and want show the stack of alloc this memory:

:004> !heap -p -a 095063c8
address 095063c8 found in
_HEAP @ 2d90000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
095063c8 0381 0000 [00] 095063e0 01b80 - (busy)
77c3c1f4 ntdll!RtlpCallInterceptRoutine+0x00000026
77c002c1 ntdll!RtlpAllocateHeapInternal+0x0004a571
77bb5d3e ntdll!RtlAllocateHeap+0x0000003e
74fea7fe windows_storage!DSA_InsertItem+0x00000089
74f2f081 windows_storage!CDSA_Base<ITEMENTRY>::AppendItem+0x00000014
74fe5864 windows_storage!CViewSettings::_AddColumn+0x0000005b
74fe5676 windows_storage!CViewSettings::_AddColumnForPropDesc+0x00000054
74fe55f6 windows_storage!CViewSettings::_LoadColumnsFromPropertyList+0x0000006b
74fe50ea windows_storage!CViewSettings::_EnsureColumns+0x00000099
74fe672b windows_storage!CViewSettings::_MapPropKeyToColumn+0x0000000f
74fe4714 windows_storage!CViewSettings::_CreateSortProperty+0x00000043
74fe4f4a windows_storage!CViewSettings::_LoadSortColumnsFromStream+0x000000be
74fe5b3c windows_storage!CViewSettings::_LoadSortColumns+0x00000055
74fe5ed2 windows_storage!CViewSettings::_EnsureViewSettings+0x00000091
74fe6ecb windows_storage!CViewSettings::GetSortColumns+0x0000002b
75d982e9 shell32!CDefView::OnGetSortColumn+0x00000059
75d7ed57 shell32!CListViewHost::_UpdateArrangeFeedback+0x000000b6
75d7d572 shell32!CListViewHost::_OnFolderFlagsChanged+0x00000350
75d7ff56 shell32!CListViewHost::OnSettingsChanged+0x00000066
75d7c736 shell32!CListViewHost::CreateControl+0x000002c6
75d98a72 shell32!CDefView::_OnCreate+0x00000156
75d9783f shell32!CDefView::WndProc+0x00000567
75d93775 shell32!CDefView::s_WndProc+0x00000045
745fbf1b user32!_InternalCallWinProc+0x0000002b
745f83ea user32!UserCallWinProcCheckWow+0x000003aa
745f7f8a user32!DispatchClientMessage+0x000000ea
745fab83 user32!__fnINLPCREATESTRUCT+0x00000073
77bdcd3d ntdll!KiUserCallbackDispatcher+0x0000004d
745f20da user32!CreateWindowInternal+0x0000017e
745f1f58 user32!CreateWindowExW+0x00000038
75d51822 shell32!SHFusionCreateWindowEx+0x00000050
75d96af1 shell32!CDefView::CreateViewWindow3+0x000002b1

and it show this is alloc by windows_storage.dll, so i guess memory leak is in windows_storage.dll, does any one have same problem, adn known how to fixed this issue ?
the windows 10 system info is

windows10 enterprise x64 10.0 version: 17134

my window_storage.dll is

:004> lmvm windows_storage
Browse full module list
start end module name
74e80000 7543a000 windows_storage (pdb symbols) e:\symbols\Windows.Storage.pdb\C819039AC4597218C70884DB22F0D8771\Windows.Storage.pdb
Loaded symbol image file: windows.storage.dll
Image path: C:\Windows\System32\windows.storage.dll
Image name: windows.storage.dll
Browse all global symbols functions data
Image was built with /Brepro flag.
Timestamp: CD2D6EC9 (This is a reproducible build file hash, not a timestamp)
CheckSum: 005C4293
ImageSize: 005BA000
File version: 10.0.17134.471
Product version: 10.0.17134.471
File flags: 0 (Mask 3F)
File OS: 40004 NT Win32
File type: 2.0 Dll
File date: 00000000.00000000
Translations: 0409.04b0
Information from resource tables:
CompanyName: Microsoft Corporation
ProductName: Microsoft® Windows® Operating System
InternalName: Windows.Storage
OriginalFilename: Windows.Storage.dll
ProductVersion: 10.0.17134.471
FileVersion: 10.0.17134.471 (WinBuild.160101.0800)
FileDescription: Microsoft WinRT Storage API
LegalCopyright: © Microsoft Corporation. All rights reserved.



Qǐyè
2/5000​
enterprise


Continue reading...
 
Back
Top