C++ umdh.exe仅显示特定堆栈分配的一小部分

C++ umdh.exe仅显示特定堆栈分配的一小部分,c++,memory-leaks,umdh,C++,Memory Leaks,Umdh,我正在尝试学习如何使用umdh.exe解决内存泄漏问题。为了做到这一点,我编写了一个示例应用程序: void MemoryLeakTest(int argc, _TCHAR* argv[]); int _tmain(int argc, _TCHAR* argv[]) { MemoryLeakTest(argc, argv); return 0; } void MemoryLeakTest(int argc, _TCHAR* argv[]) { if (argc !=

我正在尝试学习如何使用umdh.exe解决内存泄漏问题。为了做到这一点,我编写了一个示例应用程序:

void MemoryLeakTest(int argc, _TCHAR* argv[]);

int _tmain(int argc, _TCHAR* argv[])
{
    MemoryLeakTest(argc, argv);
    return 0;
}

void MemoryLeakTest(int argc, _TCHAR* argv[])
{
    if (argc != 3)
    {
        wcout << "HelloWorld.exe <number of allocations> <number of bytes>" << endl;
        getchar();
        return;
    }

    int numAllocations = _wtoi(argv[1]);
    int numBytes = _wtoi(argv[2]);

    wcout << "Num allocations: " << numAllocations << ", num bytes: " << numBytes << endl;
    wcout << "Press any key to start..." << endl; 
    getchar();

    for (int i = 0; i < numAllocations; ++i)
    {
        void* unusedMemory = new byte[numBytes];

        if ((i % (numAllocations / 100)) == 0)
        {
            wcout << i << endl;
            Sleep(100);
        }
    }

    wcout << "Press any key to finish..." << endl;
    getchar();
}
更新:TaskProcess显示私有字节和提交大小均按预期值增长

UPDATED2:DebugDiag正确地显示了一个泄漏,有10000个分配和几个指向正确位置的采样调用堆栈

知道我做错了什么吗

谢谢大家!

+   17000 (  17000 -      0)     17 allocs  BackTraceB5023D4D
+      17 (     17 -      0)    BackTraceB5023D4D   allocations

ntdll!memset+165B9
MSVCR120!malloc+5B
MSVCR120!operator new+1F
HelloWorld!MemoryLeakTest+108 (c:\my\main\private\testproject\debugit\helloworld\helloworld.cpp, 40)
HelloWorld!wmain+9 (c:\my\main\private\testproject\debugit\helloworld\helloworld.cpp, 16)
HelloWorld!__tmainCRTStartup+10F (f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c, 623)
KERNEL32!BaseThreadInitThunk+D
ntdll!RtlUserThreadStart+1D