FastMM is a free (source available) memory leak detector, already integrated in the latest Delphi versions. I never had a need for anything else.
It's much better BTW to limit the possibilities of memory leaks when coding, instead of finding them later. Some tips:
Always use try and finally in your code to free created objects. Better to write this code immediately, and then write code to use the objects. Even better to make use of IDE functionality like Code Templates.
Only use functions that return dynamically allocated objects when absolutely necessary. It's generally better to pass objects as parameters than create and return them. For example this
procedure getChoices(var AChoices: TStrings);
would be much better than
function getChoices: TStrings;
as there is no potential of accidently leaking the created TStrings object.
We use EurekaLog at our work in Delphi 7. It's an exception handler component which gives very detailed information about exceptions (including callstack! environment variables, etc) even for access violations. But another great feature is that you can tell it to error on memory leaks too, which shows the exact line of code where the memory/object was allocated in the first place! It is a commerical product but I would still highly recommend it.
You may want to give a look at this CodeRage 2 session: Fighting Memory Leaks for Dummies.
It mainly shows how to use FastMM to prevent/detect memory leaks in Delphi. Was for D2007 but still relevant for D2009.
AQTime is very good. It also does other things like profiling for performance. And it does not require any changes in your code. Of course compiling with debug info helps giving better results.
FastMM is a free (source available) memory leak detector, already integrated in the latest Delphi versions. I never had a need for anything else.
It's much better BTW to limit the possibilities of memory leaks when coding, instead of finding them later. Some tips:
Always use try and finally in your code to free created objects. Better to write this code immediately, and then write code to use the objects. Even better to make use of IDE functionality like Code Templates.
Only use functions that return dynamically allocated objects when absolutely necessary. It's generally better to pass objects as parameters than create and return them. For example this
would be much better than
as there is no potential of accidently leaking the created TStrings object.
I use MadExcept because it's free for personal use.
I always use ReportMemoryLeaksOnShutdown := (DebugHook <> 0); so that I only get the leaks reported if I'm debugging.
ps wanted to place this in a comment but I dont have the rights yet..
We use EurekaLog at our work in Delphi 7. It's an exception handler component which gives very detailed information about exceptions (including callstack! environment variables, etc) even for access violations. But another great feature is that you can tell it to error on memory leaks too, which shows the exact line of code where the memory/object was allocated in the first place! It is a commerical product but I would still highly recommend it.
You may want to give a look at this CodeRage 2 session: Fighting Memory Leaks for Dummies. It mainly shows how to use FastMM to prevent/detect memory leaks in Delphi. Was for D2007 but still relevant for D2009.
AQTime is very good. It also does other things like profiling for performance. And it does not require any changes in your code. Of course compiling with debug info helps giving better results.