SafeMM Debug Memory Manager available on CodeCentral

Posted by on in Blogs
In my CodeRage talk,  Debugging Techniques for Delphi, I gave a short demo of using 2 different debug heap managers to help track down memory issues.  In the demo, I showed FastMM and another memory manager called SafeMM.  FastMM has been around for a number of years, and I'm sure many of you have used it in the "fulldebug" mode to help find memory errors.  SafeMM, on the other hand, has only been available publicly since my CodeRage session.  The source files are available on CodeCentral.

SafeMM works by not immediately re-using freed blocks and using the page protection flags that are part of the operating system.  It does an excellent job of detecting reads and writes beyond the boundaries of a memory block as well as any access to freed memory.   FastMM can also detect these types of errors, but it doesn't typically detect them right when they occur.

Because of the way it is designed, SafeMM will require significantly more memory than the normal memory manager and typically cannot be used for extended periods of time without causing "out of memory" errors.   For best results, try to use SafeMM to test a very specific set of steps for a failure.

If you have an elusive bug that you suspect may be related to heap corruption give SafeMM a try.  It works great.

Many thanks to Ben Taylor for giving permission to share this useful debugging tool with the Delphi / C++ Builder community!

P.S. If you want to see just the debug memory manager demo from the CodeRage talk you can fast forward to about the 23 minute mark.

Comments

  • Guest
    Kryvich Saturday, 17 October 2009

    It's a great utility for a debugging!

    We discussed such technics of debugging almost two years ago at the DelphiKingdom.ru . Thanks you and Ben Taylor for an implementing of it!

  • Guest
    Dimitrij Kowalski Monday, 16 November 2009

    Mark, why don't you register your blog under delphifeeds.com?

    I've discovered it today, only by an accident...! :-)

  • Guest
    Ermoghen Thursday, 18 March 2010

    Hello. I discovered it while looking for a way to trace the source of a nasty error. Unfortunately, I cannot open the .dproj file in RAD Studio 2007.

  • Guest
    Paulo Eduardo Neves Thursday, 27 October 2011

    It looks cool, but I downloaded it and don't know how to start. A readme.txt woud be welcome.

    Ive compiled my project with SafeMM as the first unit in project, rebuild it, but I'm still getting the old access violation message.

  • Guest
    Kevin Killion Friday, 13 January 2012

    Wow, same reaction here. I'm having a serious AV problem, and people suggested getting SafeMM. So, I downloaded the ZIP. Unzipping leaves this:

    BorlndMM.dproj
    BorlndMM.dpr
    BorlndMM.res
    SafeMMInstall.pas
    SafeMM.pas

    So now what??? Yes, a "readme.txt" would be very helpful.

  • Guest
    Kevin Killion Friday, 13 January 2012

    OK, a little more searching and a little more info. It tuns out that there exists a CodeRage presentation from 2009 that includes discussion of Safee and FastMM:

    http://cc.embarcadero.com/javascript/play.html?u=y&w=1024&h=768&s=18.4MB&f=http%3a%2f%2fcc.embarcadero.com%2fdownload.aspx%3fid%3d27285%26file%3dMarkEdington_Debugging.swf&d=http%3a%2f%2fcc.embarcadero.com%2fdownload.aspx%3fid%3d27285

    Unfortunately, while this is a VERY cool and helpful demo of how you can use them, it says nothing about how to install them in the first place.

  • Guest
    Radek Cervinka Tuesday, 03 July 2012

    Installation: informations are included in SafeMM.pas .

  • Please login first in order for you to submit comments
  • Page :
  • 1