Welcome to Sign in | Join | Help
in Search

LeakDiag confusion

Last post 06-18-2008, 9:58 AM by Anonymous. 8 replies.
Sort Posts: Previous Next
  •  12-26-2007, 6:34 PM 36

    LeakDiag confusion

    I've been playing around with LeakDiag and am left all confused. I have been reading the book, looking at LeakDiag help and still not able to understand how one is supposed to interpret those log files.

     Some of my questions:

    1. What version of LeakDiag is the latest. The download I have is 1.25 and is dated 2002. However, somewhere here the one of the posts at the end allude to a 1.31.xx.yyy version. http://groups.google.com/group/microsoft.public.windbg/browse_thread/thread/f7be3ad0aef62120/657ccfeb114b7bd2?hl=en&lnk=st&q=LeakDiag#657ccfeb114b7bd2

    2. I tried a simple application like below:

    #include "stdafx.h"
    #include <conio.h>
    #include <memory>

    int _tmain(int argc, _TCHAR* argv[])
    {
     getch();
     char* p = (char*)malloc(30);
     getch();
     return 0;
    }

     using VS2005 IDE. I run this app, it stops at first getch at which point I run leakdiag, select this app, select C Runtime Allocator, hit Start.

    I now, switch back to the target application console , punch in a key to let it go past the malloc , and switch back to LeakDiag and hit Log. I would've thought this should dump the malloced entry in the log file, but I see that the log file is not generated at all.

     What is going on ?

     P.S. I have tried an MFC application also, putting in a memory leak like above and then generating logs. I do see the logs, but there is no stack trace whatsoever which can be deciphered although I am pointing to the folder containing the exe.

    BTW, I am running WinXP SP2

     

  •  12-26-2007, 9:24 PM 37 in reply to 36

    Re: LeakDiag confusion

    Hi, 

    Did you set the correct symbol path in LeakDiag? Also, can you share parts of the log file that was generated?

    Thanks,

    Mario

  •  12-27-2007, 9:36 AM 38 in reply to 37

    Re: LeakDiag confusion

    Hi Mario,

    Thanks for the reply. First off, kudos on the book. It is well written and I think you have succeeded in revealing a lot of hidden gems for debugging. LeakDiag is one such discovery for me :)

     As for the issue, this is what I found today. All the while I was choosing the wrong allocator. I would've though using C runtime allocator would trap calls to malloc, but alas, it does not. With C Runtime allocator, this is the log I got:

      <LEAKS ver="1.25.28.2201" />
    - <SUMMARY_INFO>
      <FILENAME>C:\tmp\AALeak\Debug\AALeak.exe</FILENAME>
      <PID>2460</PID>
      <OS ver="5.1.2600" sp="2.0" name="Windows XP Professional Service Pack 2" />
    - <LEAKDIAG_SETTINGS>
      <ALLOCATOR num="6" state="1" />
      </LEAKDIAG_SETTINGS>
    - <MEMORY_INFO>
      <LEAKDIAG memusage="1157792" />
      <GLOBALMEM MemoryLoad="64" TotalPhys="1072930816" AvailPhys="0" TotalPageFile="382177280" AvailPageFile="0" TotalVirtual="2581164032" AvailVirtual="0" AvailExtendedVirtual="1812205568" />
      <PROCESSMEM PeakVirtualSize="22179840" VirtualSize="19386368" PageFaultCount="2084" PeakWorkingSetSize="8343552" WorkingSetSize="8183808" QuotaPeakPagedPoolUsage="15668" QuotaPagedPoolUsage="11576" QuotaPeakNonPagedPoolUsage="2480" PagefileUsage="7819264" PeakPagefileUsage="7970816" />
      </MEMORY_INFO>
      <MODULES />
      </SUMMARY_INFO>
    Note that the Leaks section is empty.
    Subsequently, I did the same test using the Windows Heap allocator, and I do see the stack trace now. This is what I see:
    - <LEAKS ver="1.25.28.2201">
    - <STACK numallocs="01" size="066" totalsize="066">
    - <STACKSTATS>
      <SIZESTAT size="066" numallocs="01" />
      <HEAPSTAT handle="350000" numallocs="01" />
      </STACKSTATS>
      <FRAME num="0" dll="MSVCR80D.dll" function="malloc_base" offset="0xEC" filename="" line="" addr="0x10212F4C" />
      <FRAME num="1" dll="MSVCR80D.dll" function="malloc_dbg" offset="0x2D5" filename="" line="" addr="0x1021AE15" />
      <FRAME num="2" dll="MSVCR80D.dll" function="malloc_dbg" offset="0x69" filename="" line="" addr="0x1021ABA9" />
      <FRAME num="3" dll="MSVCR80D.dll" function="malloc" offset="0x19" filename="" line="" addr="0x1021AB29" />
      <FRAME num="4" dll="AALeak.exe" function="wmain" offset="0x37" filename="c:\tmp\aaleak\aaleak.cpp" line="11" addr="0x4113E7" />
      <STACKID>004E4008</STACKID>
      </STACK>
      </LEAKS>
    Question. Why this behavior? Per documentation on LeakDiag C runtime allocator should trap malloc, new, callocs etc.
  •  12-27-2007, 1:32 PM 40 in reply to 38

    Re: LeakDiag confusion

    Hi Mario,

    I think I might have nailed the reason at least for Visual Studio 6.0 compiled exe. All along, my Visual Studio 6.0 project settings were using static linking with CRT. When I did switch to multi-threaded dll option to use the crt dlls, I am able to see the C runtime allocator working fine.

    However,  

    I still see that with VS2005 compiled executable, this doesn't happen. Using dependencywalker I see that malloc is infact being imported from MSVCR80.dll.

    Does LeakDiag take care of CRT dlls other than MSVCRT.dll ?

    Thanks

    Kiran

     

  •  01-29-2008, 3:16 AM 47 in reply to 36

    Re: LeakDiag confusion

    Hi,

     together with the LeadDiag tool, there come two packages LDGrapher and LDParser, giving a nice view of the leak. The latest version of LeakDiag I got is 1.31 (obtained it via Microsoft Premier Support). I explained the usage of it in my article about production debugging (http://www.microsoft.com/belux/msdn/nl/community/articles/feb05_applicationdebugging.mspx). Hope this helps.

  •  06-03-2008, 12:27 AM 195 in reply to 36

    Re: LeakDiag confusion

    kirants:

    I've been playing around with LeakDiag and am left all confused. I have been reading the book, looking at LeakDiag help and still not able to understand how one is supposed to interpret those log files.

     Some of my questions:

    1. What version of LeakDiag is the latest. The download I have is 1.25 and is dated 2002. However, somewhere here the one of the posts at the end allude to a 1.31.xx.yyy version. http://groups.google.com/group/microsoft.public.windbg/browse_thread/thread/f7be3ad0aef62120/657ccfeb114b7bd2?hl=en&lnk=st&q=LeakDiag#657ccfeb114b7bd2

    2. I tried a simple application like below:

    #include "stdafx.h"
    #include <conio.h>
    #include <memory>

    int _tmain(int argc, _TCHAR* argv[])
    {
     getch();
     char* p = (char*)malloc(30);
     getch();
     return 0;
    }

     using VS2005 IDE. I run this app, it stops at first getch at which point I run leakdiag, select this app, select C Runtime Allocator, hit Start.

    I now, switch back to the target application console , punch in a key to let it go past the malloc , and switch back to LeakDiag and hit Log. I would've thought this should dump the malloced entry in the log file, but I see that the log file is not generated at all.

     What is going on ?

     P.S. I have tried an MFC application also, putting in a memory leak like above and then generating logs. I do see the logs, but there is no stack trace whatsoever which can be deciphered although I am pointing to the folder containing the exe.

    BTW, I am running WinXP SP2

     

  •  06-06-2008, 12:09 PM 227 in reply to 36

    Re: LeakDiag confusion

    kirants:

    I've been playing around with LeakDiag and am left all confused. I have been reading the book, looking at LeakDiag help and still not able to understand how one is supposed to interpret those log files.

     Some of my questions:

    1. What version of LeakDiag is the latest. The download I have is 1.25 and is dated 2002. However, somewhere here the one of the posts at the end allude to a 1.31.xx.yyy version. http://groups.google.com/group/microsoft.public.windbg/browse_thread/thread/f7be3ad0aef62120/657ccfeb114b7bd2?hl=en&lnk=st&q=LeakDiag#657ccfeb114b7bd2

    2. I tried a simple application like below:

    #include "stdafx.h"
    #include <conio.h>
    #include <memory>

    int _tmain(int argc, _TCHAR* argv[])
    {
     getch();
     char* p = (char*)malloc(30);
     getch();
     return 0;
    }

     using VS2005 IDE. I run this app, it stops at first getch at which point I run leakdiag, select this app, select C Runtime Allocator, hit Start.

    I now, switch back to the target application console , punch in a key to let it go past the malloc , and switch back to LeakDiag and hit Log. I would've thought this should dump the malloced entry in the log file, but I see that the log file is not generated at all.

     What is going on ?

     P.S. I have tried an MFC application also, putting in a memory leak like above and then generating logs. I do see the logs, but there is no stack trace whatsoever which can be deciphered although I am pointing to the folder containing the exe.

    BTW, I am running WinXP SP2

     

  •  06-11-2008, 10:37 AM 239 in reply to 36

    Re: LeakDiag confusion

    kirants:

    I've been playing around with LeakDiag and am left all confused. I have been reading the book, looking at LeakDiag help and still not able to understand how one is supposed to interpret those log files.

     Some of my questions:

    1. What version of LeakDiag is the latest. The download I have is 1.25 and is dated 2002. However, somewhere here the one of the posts at the end allude to a 1.31.xx.yyy version. http://groups.google.com/group/microsoft.public.windbg/browse_thread/thread/f7be3ad0aef62120/657ccfeb114b7bd2?hl=en&lnk=st&q=LeakDiag#657ccfeb114b7bd2

    2. I tried a simple application like below:

    #include "stdafx.h"
    #include <conio.h>
    #include <memory>

    int _tmain(int argc, _TCHAR* argv[])
    {
     getch();
     char* p = (char*)malloc(30);
     getch();
     return 0;
    }

     using VS2005 IDE. I run this app, it stops at first getch at which point I run leakdiag, select this app, select C Runtime Allocator, hit Start.

    I now, switch back to the target application console , punch in a key to let it go past the malloc , and switch back to LeakDiag and hit Log. I would've thought this should dump the malloced entry in the log file, but I see that the log file is not generated at all.

     What is going on ?

     P.S. I have tried an MFC application also, putting in a memory leak like above and then generating logs. I do see the logs, but there is no stack trace whatsoever which can be deciphered although I am pointing to the folder containing the exe.

    BTW, I am running WinXP SP2

     

  •  06-18-2008, 9:58 AM 257 in reply to 36

    Re: LeakDiag confusion

    kirants:

    I've been playing around with LeakDiag and am left all confused. I have been reading the book, looking at LeakDiag help and still not able to understand how one is supposed to interpret those log files.

     Some of my questions:

    1. What version of LeakDiag is the latest. The download I have is 1.25 and is dated 2002. However, somewhere here the one of the posts at the end allude to a 1.31.xx.yyy version. http://groups.google.com/group/microsoft.public.windbg/browse_thread/thread/f7be3ad0aef62120/657ccfeb114b7bd2?hl=en&lnk=st&q=LeakDiag#657ccfeb114b7bd2

    2. I tried a simple application like below:

    #include "stdafx.h"
    #include <conio.h>
    #include <memory>

    int _tmain(int argc, _TCHAR* argv[])
    {
     getch();
     char* p = (char*)malloc(30);
     getch();
     return 0;
    }

     using VS2005 IDE. I run this app, it stops at first getch at which point I run leakdiag, select this app, select C Runtime Allocator, hit Start.

    I now, switch back to the target application console , punch in a key to let it go past the malloc , and switch back to LeakDiag and hit Log. I would've thought this should dump the malloced entry in the log file, but I see that the log file is not generated at all.

     What is going on ?

     P.S. I have tried an MFC application also, putting in a memory leak like above and then generating logs. I do see the logs, but there is no stack trace whatsoever which can be deciphered although I am pointing to the folder containing the exe.

    BTW, I am running WinXP SP2

     

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems