[Download] MemAnalysis - Native memory leak analysis tool

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. 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.

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.

This article is part of the GWB Archives. Original Author: Gaurav Khanna

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.