Catching memory leaks in Delphi: a definitive list of tools
[SHOWTOGROUPS=4,20]
Catching memory leaks in Delphi: a definitive list of tools
Detecting memory leaks is a very important task in Delphi development. I’ve Для просмотра ссылки Войдиили Зарегистрируйся, stressing that in server applications like the ones built with Для просмотра ссылки Войди или Зарегистрируйся this is even more important.
With the Для просмотра ссылки Войдиили Зарегистрируйся, this will become even more relevant. A unified memory management Для просмотра ссылки Войди или Зарегистрируйся, and Для просмотра ссылки Войди или Зарегистрируйся.
As everything in life, this change isn’t 100% good or bad, Для просмотра ссылки Войдиили Зарегистрируйся, but one thing is clear: the way memory is managed now is the same in all platforms, so the ways to detect memory leaks in different platforms are more similar now. I personally think this is a good thing. It’s also important to note that this doesn’t necessarily mean “more leaks” in mobile platforms. The “old” (still valid when I’m writing this article) Для просмотра ссылки Войди или Зарегистрируйся also had its problems, and in my opinion harder to detect, like Для просмотра ссылки Войди или Зарегистрируйся.
But well, enough with this too long introduction. The humble purpose of this article is to be a definitive and up-to-date list of all tools that you can use to detect memory leaks in Delphi applications. Pointing out that memory management is unified just means that these tools are even more relevant than ever. Detecting and fixing a memory leak in Windows will help even more that your non-Windows applications will not have memory leaks as well.
So, to the list!
Для просмотра ссылки Войдиили Зарегистрируйся (Free)
FastMM (or to be more specific, FastMM4) is the de-facto standard tool to detect memory leaks in Delphi. The reason is simple: it’s the Для просмотра ссылки Войдиили Зарегистрируйся, so it’s already built-in and ready to use.
Since FastMM allocates and deallocates memory in your application, who else is better to report the blocks that have not been deallocated? All that it takes to start working with it is add a single line in your project:
ReportMemoryLeaksOnShutdown := True;
And voilà, your application will report all memory leaks when it shuts down. If there are leaks at the end of your application, a dialog will be displayed showing all the leaks.
All Delphi developers should add that line to their applications. Really. I don’t even know why this is not added by default in Delphi, at least wrapped by a {$IFDEF DEBUG} directive. Maybe for historical reasons.
So, if it’s built-in, default, works, why don’t we finish this article here, then? Well, there are some gotchas.
Delphi includes a stripped out version of FastMM4. It doesn’t have all the nice debugging tools you need (to know, for example, where in the code your leaked memory was allocated). To do that, you have to use the full FastMM4 version, available on the Для просмотра ссылки Войдиили Зарегистрируйся.
You also have to use a DLL for the full debugging features; it’s not cross-platform: it only officially works for Windows (it looks like a macOS version is available in the official repo, but I never tried it). And even though it has lots of features, to use it Для просмотра ссылки Войдиили Зарегистрируйся, which might not be comfortable for some users.
But all in all, is a great tool, the “standard” tool to get memory leaks in Delphi. (Side note: Для просмотра ссылки Войдиили Зарегистрируйся. We haven’t tested it yet but it looks like it brings a Для просмотра ссылки Войди или Зарегистрируйся, we can’t wait to test it in TMS XData.)
Pros
Для просмотра ссылки Войдиили Зарегистрируйся (Free)
Delphi LeakCheck is another great option for detecting memory leaks. It’s also free, open source, and has some advantages over FastMM: it’s cross-platform, meaning you can check leaks directly in mobile and Linux applications; and it integrates very well with unit test frameworks (namely Для просмотра ссылки Войдиили Зарегистрируйся and Для просмотра ссылки Войди или Зарегистрируйся).
The way to get started with it is similar to FastMM: add LeakCheck unit as the first used unit in your dpr uses clause, and it will plugin and be ready to use. Setting up for unit testing is a little more complicated though, but that’s part of the game.
One small disadvantage is that to use it you are almost on your own: the project hasn’t received updates for a while (which isn’t necessarily bad since it’s working). But that means probably you won’t get much help directly from the author (I never tried, to be fair). There is also not much information about it in the web, I just found one Для просмотра ссылки Войдиили Зарегистрируйсяt besides the detailed description in the official Bitbucket repository itself.
Pros
Для просмотра ссылки Войдиили Зарегистрируйся (Commercial)
Delaker is the only commercial tool in the list that is exclusively dedicated to catch memory leaks. That reflects in the product, which provides you with really nice features for detecting memory leaks.
Differently from the previous two tools, and similar to the following ones, it has a friendly GUI for you to setup the environment and see the results, which can be used standalone or integrated to Delphi IDE. It can also detect way more types of memory leaks: GDI leaks, leaks of Windows USER objects and handles, leaks in Windows APIs, in 3rd party DLLs, etc. Exactly because of that, it provides options for you to easily ignore several types of leaks – if you don’t, you will get a gazillion of leaks in just a regular app execution.
Another nice feature is the ability to take snapshots of the memory allocation. This allows you to detect leaks not only during the lifetime of your whole application, but in some specific operations of it.
Pros
[/SHOWTOGROUPS]
Catching memory leaks in Delphi: a definitive list of tools
Detecting memory leaks is a very important task in Delphi development. I’ve Для просмотра ссылки Войди
With the Для просмотра ссылки Войди
As everything in life, this change isn’t 100% good or bad, Для просмотра ссылки Войди
But well, enough with this too long introduction. The humble purpose of this article is to be a definitive and up-to-date list of all tools that you can use to detect memory leaks in Delphi applications. Pointing out that memory management is unified just means that these tools are even more relevant than ever. Detecting and fixing a memory leak in Windows will help even more that your non-Windows applications will not have memory leaks as well.
So, to the list!
Для просмотра ссылки Войди

FastMM (or to be more specific, FastMM4) is the de-facto standard tool to detect memory leaks in Delphi. The reason is simple: it’s the Для просмотра ссылки Войди
Since FastMM allocates and deallocates memory in your application, who else is better to report the blocks that have not been deallocated? All that it takes to start working with it is add a single line in your project:
ReportMemoryLeaksOnShutdown := True;
And voilà, your application will report all memory leaks when it shuts down. If there are leaks at the end of your application, a dialog will be displayed showing all the leaks.

All Delphi developers should add that line to their applications. Really. I don’t even know why this is not added by default in Delphi, at least wrapped by a {$IFDEF DEBUG} directive. Maybe for historical reasons.
So, if it’s built-in, default, works, why don’t we finish this article here, then? Well, there are some gotchas.
Delphi includes a stripped out version of FastMM4. It doesn’t have all the nice debugging tools you need (to know, for example, where in the code your leaked memory was allocated). To do that, you have to use the full FastMM4 version, available on the Для просмотра ссылки Войди
You also have to use a DLL for the full debugging features; it’s not cross-platform: it only officially works for Windows (it looks like a macOS version is available in the official repo, but I never tried it). And even though it has lots of features, to use it Для просмотра ссылки Войди
But all in all, is a great tool, the “standard” tool to get memory leaks in Delphi. (Side note: Для просмотра ссылки Войди
Pros
- Free;
- Full source code;
- Built-in in Delphi;
- Easy to setup;
- Lots of advanced features.
- Windows only;
- Needs external DLL for debugging features;
- Not user-friendly to setup and use advanced features (no built-in GUI);
- Only reports leaks on memory allocated by FASTMM itself.
Для просмотра ссылки Войди
Delphi LeakCheck is another great option for detecting memory leaks. It’s also free, open source, and has some advantages over FastMM: it’s cross-platform, meaning you can check leaks directly in mobile and Linux applications; and it integrates very well with unit test frameworks (namely Для просмотра ссылки Войди
The way to get started with it is similar to FastMM: add LeakCheck unit as the first used unit in your dpr uses clause, and it will plugin and be ready to use. Setting up for unit testing is a little more complicated though, but that’s part of the game.
One small disadvantage is that to use it you are almost on your own: the project hasn’t received updates for a while (which isn’t necessarily bad since it’s working). But that means probably you won’t get much help directly from the author (I never tried, to be fair). There is also not much information about it in the web, I just found one Для просмотра ссылки Войди
Pros
- Free;
- Full source code;
- Cross-plataform;
- Integrates well with unit testing (DUnit and DUnitX).
- Not much information around about how to use it;
- No recent updates, no official support;
Для просмотра ссылки Войди

Delaker is the only commercial tool in the list that is exclusively dedicated to catch memory leaks. That reflects in the product, which provides you with really nice features for detecting memory leaks.

Differently from the previous two tools, and similar to the following ones, it has a friendly GUI for you to setup the environment and see the results, which can be used standalone or integrated to Delphi IDE. It can also detect way more types of memory leaks: GDI leaks, leaks of Windows USER objects and handles, leaks in Windows APIs, in 3rd party DLLs, etc. Exactly because of that, it provides options for you to easily ignore several types of leaks – if you don’t, you will get a gazillion of leaks in just a regular app execution.
Another nice feature is the ability to take snapshots of the memory allocation. This allows you to detect leaks not only during the lifetime of your whole application, but in some specific operations of it.
Pros
- Friendly GUI that can be used standalone or integrated into Delphi IDE;
- Detects all types of leaks;
- Command-line tool for CI integration;
- Memory usage snapshots;
- Official support;
- Paid license ($99 for Home License, $399 for Single Developer License);
- Windows only;
[/SHOWTOGROUPS]