|
|
LeakDiag confusion
Last post 06-18-2008, 9:58 AM by Anonymous. 8 replies.
-
12-26-2007, 6:34 PM |
-
kirants
-
-
-
Joined on 12-27-2007
-
-
Posts 5
-
-
|
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 |
-
marioh
-
-
-
Joined on 12-03-2006
-
-
Posts 19
-
-
|
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 |
|
|
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" /> <FILENAME>C:\tmp\AALeak\Debug\AALeak.exe</FILENAME> <OS ver="5.1.2600" sp="2.0" name="Windows XP Professional Service Pack 2" /> <ALLOCATOR num="6" state="1" /> </LEAKDIAG_SETTINGS> <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> </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"> <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 |
-
kirants
-
-
-
Joined on 12-27-2007
-
-
Posts 5
-
-
|
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 |
-
06-03-2008, 12:27 AM |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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
|
|
|
|
|