Geeks With Blogs

News
WinToolZone - Spelunking Microsoft Technologies
I work as a developer on the Common Language Runtime (CLR) team, specifically in the areas of exception handling and CLR hosting.
Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Inside and Out... An attempt to understand technology better...

Advanced Windows Debugging got me hooked onto Detours and that led me to experiment with it a bit more. It resulted in this. Over the past three days, I have been working on using Detours to build a memory leak detection tool. MemAnalysis is finally done (v1, that is) and can track memory allocation and release when done using the following APIs:

  • VirtualAlloc
  • VirtualFree
  • HeapAlloc
  • HeapFree
  • HeapDestroy

Once the application being analyzed exits, MemAnalysis produces a report with details on how many allocations took place, how many of them were freed and how much memory was not released. Below is a sample output:

Total Allocations: 8605
Total Virtual allocations: 1
Freed Virtual allocations: 1
Virtual allocation leaked size: 0 bytes

Total Heap allocations: 8604
Freed Heap allocations: 4189
Heap allocation leaked size: 1965244 bytes
==============================================

2344 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019CDD0h
548 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019D700h
16 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019C718h
308 bytes were leaked; Allocation method: Heap; Handle: 10000h; Address: 00010588h
60 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019C4F0h
24 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 00184830h
1826 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019D700h
2032 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019DE30h
538 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019D700h
104 bytes were leaked; Allocation method: Heap; Handle: 180000h; Address: 0019A600h

It is a free download and can be downloaded from here.

Note: If not already present on your machine, you need to have VC++ 2008 runtimes installed. The X86 version can be downloaded from here and the X64 version is here.

Posted on Wednesday, December 26, 2007 2:58 PM Debugging , Downloads , Development , Windows API | Back to top


Comments on this post: [Download] MemAnalysis - Native memory leak analysis tool

# re: [Download] MemAnalysis - Native memory leak analysis tool
Requesting Gravatar...
Could not execute the program.

"The system cannot execute the specified program".
Pls give more info....
Left by surya on Dec 27, 2007 1:34 AM

# re: [Download] MemAnalysis - Native memory leak analysis tool
Requesting Gravatar...
The blog is good
Left by Venkatesan on Dec 27, 2007 10:45 PM

Your comment:
 (will show your gravatar)


Copyright © Gaurav Khanna | Powered by: GeeksWithBlogs.net