MemTrack

Requirements:

Steps to add MemTrack to an MFC project:

  1. Open MemTrack.dsw with Visual C++ 6.0. From the Projects menu, select Batch Build and Rebuild All. This will build MemTrack for the windows CE 2.11 emulator in both DEBUG and RELEASE modes, and copy MemTrackd.dll and MemTrack.dll into the emulator's directory.
  2. For convenience, copy MemTrack.h, MemTrack.lib and MemTrackd.lib into a common directory, such as C:\MemTrack.
  3. Close the MemTrack project and open an MFC project of yours.
  4. Add #include <MemTrack.h> as the last include file in Stdafx.h.
  5. Replace any occurrence of ::new and ::delete by new and delete respectively.
  6. Add the directory where MemTrack.h resides (see Step 2) in the project settings: from the Projects menu, select Settings and then C/C++; select Preprocessor from the Category combo box, and add the path under "Additional include directories".
  7. Add the directory where MemTrack.lib and MemTrackd.lib resides (see Step 2) in the project settings: still within the Projects Settings dialog box, select the Link tab, and Input from the Category combo box; then add the path under "Additional library path".
  8. Rebuild the project (i.e. Rebuild All from the Projects menu) in DEBUG mode and run it (in the emulator).
  9. Any memory leak will be dumped in the Output window. Double-clicking on each line describing a leak will open the file and position the cursor on the related line. Note that since some objects are allocated in applications but released in the MFC library, some memory leaks will always be detected.
  10. You can also build your project in RELEASE mode, in which case a single message box will be displayed upon termination if memory leaks are detected.

Enjoy!

Send comments to: jeangareau@yahoo.com