как работает umdh.exe -g?
От: kgrach Россия  
Дата: 03.10.13 09:57
Оценка:
У umdh.exe, из набора Debugging tools, есть ключик
-g
Logs the heap blocks that are not referenced by the process ("garbage collection").

Суть моего вопроса не понимаю как этот ключ работает.

Собираю свой пример с утечкой в куче для проверки работоспособности ключа

void f_leak(void){

HANDLE m_hHeap =HeapCreate( HEAP_GROWABLE | HEAP_ZERO_MEMORY, 0, 0);

BYTE* pByte = (BYTE*) HeapAlloc( m_hHeap, HEAP_ZERO_MEMORY, 1<<20);

pByte = (BYTE*) HeapAlloc( m_hHeap, HEAP_ZERO_MEMORY, 1<<21);
}

main (){

// делаю первый snapshot... umdh.exe -pn:MyProg.exe -f:1.mem

f_leak();

// делаю второй и третий snapshot-ы umdh.exe -pn:MyProg.exe -f:2_g.mem -g
// umdh.exe -pn:MyProg.exe -f:2.mem
...
}


затем сравниваю umdh 1.mem 2_g.mem > 12_g.mem
Вижу все stack trace с новыми выделениями в куче

+ 1ffff0 ( 1ffff0 — 0) 1 allocs BackTrace214100
+ 1 ( 1 — 0) BackTrace214100 allocations

ntdll!RtlUlonglongByteSwap+00000B52
leakDiag_test!f_leak+0000003A (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 36)
leakDiag_test!main+00000023 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 50)
leakDiag_test!__tmainCRTStartup+000001BF (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 555)
leakDiag_test!mainCRTStartup+0000000F (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 371)
kernel32!BaseThreadInitThunk+00000012
ntdll!RtlInitializeExceptionChain+00000063
ntdll!RtlInitializeExceptionChain+00000036

+ ffff0 ( ffff0 — 0) 1 allocs BackTrace2140AC
+ 1 ( 1 — 0) BackTrace2140AC allocations

ntdll!RtlUlonglongByteSwap+00000B52
leakDiag_test!f_leak+00000026 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 34)
leakDiag_test!main+00000023 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 50)
leakDiag_test!__tmainCRTStartup+000001BF (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 555)
leakDiag_test!mainCRTStartup+0000000F (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 371)
kernel32!BaseThreadInitThunk+00000012
ntdll!RtlInitializeExceptionChain+00000063
ntdll!RtlInitializeExceptionChain+00000036

+ 20 ( 20 — 0) 1 allocs BackTrace214058
+ 1 ( 1 — 0) BackTrace214058 allocations

ntdll!RtlUlonglongByteSwap+00000B52
ntdll!RtlRunOnceBeginInitialize+0000008E
ntdll!RtlInitializeCriticalSectionAndSpinCount+00000019
ntdll!RtlCreateHeap+00000372
KERNELBASE!HeapCreate+00000050
leakDiag_test!f_leak+00000012 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 32)
leakDiag_test!main+00000023 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 50)
leakDiag_test!__tmainCRTStartup+000001BF (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 555)
leakDiag_test!mainCRTStartup+0000000F (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 371)
kernel32!BaseThreadInitThunk+00000012
ntdll!RtlInitializeExceptionChain+00000063
ntdll!RtlInitializeExceptionChain+00000036


Total increase == 300000 requested + 38 overhead = 300038

Хотя ожидал увидеть, только этот

+ ffff0 ( ffff0 — 0) 1 allocs BackTrace2140AC
+ 1 ( 1 — 0) BackTrace2140AC allocations

ntdll!RtlUlonglongByteSwap+00000B52
leakDiag_test!f_leak+00000026 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 34)
leakDiag_test!main+00000023 (d:\work\test\leakdiag_test\leakdiag_test\main.cpp, 50)
leakDiag_test!__tmainCRTStartup+000001BF (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 555)
leakDiag_test!mainCRTStartup+0000000F (f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, 371)
kernel32!BaseThreadInitThunk+00000012
ntdll!RtlInitializeExceptionChain+00000063
ntdll!RtlInitializeExceptionChain+00000036


смотрю чем отличаются 2.mem 2_g.mem, у 2_g.mem в конце файла появляются записи

*- — — — — — — — — — Leaks detected — — — — — — — — — —


*- — — — — — — — — — End of Leaks — — — — — — — — — —

В гугле нашел единственное упоминание про работу этого ключа

http://stackoverflow.com/questions/1513096/umdh-exe-g-option

Вопрос
Am using umdh.exe to analyze possible memory leak. I have a question regarding the '-g' option of umdh.exe. I searched the web, and the available documentation says "Logs the heap blocks that are not referenced by the process ("garbage collection")."

Does that mean umdh.exe -g already lists the memory that has leaked (since there are no references to it in the process)?

Please clarify.

Thanks in advance, Kiran

Ответ

Does not indicate failure, only indicates that the memory is no longer in use by the process and can now be collected by garbage collection. This information is used to evaluate how the process behaves, and that their values will depend on how the application operates.

Что я делаю не так
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.