Wednesday 5 June 2019

Take a "leak"

- or introducing Deleaker - now available for Delphi/C++Builder/RAD Studio



Since we in RAD Studio need to be able to master the fine art of manual memory management - things might leak if you do not pay attention and follow the rules. The most basic rule being: What you create - you must "destroy" (read free).


The adventures into "Automatic Reference Counting" has been announced to be reverted, and all supported platforms will eventually be back to the manual model - being apparently more efficient and what most of us are used to, that gives us the feeling of control we like :)

But even if ARC eventually goes away - I would more than ever recommend Dalija Prasnikar's "Delphi Memory Management for Classic and ARC Compilers" - a must read by someone who knows what she talks about.

That means it is also interesting when a "new" player enters the market for detecting memory leaks, since even if you think your code is perfect - you might be depending on frameworks or components that combined with the way you use them - could leak.

Deleaker which has been available as a plugin for Visual Studio for many years - and gotten its fame there - is now also available as an add-on for RAD Studio. And when doing a test run, I was very pleased with the simplicity - I did not have to spend time tweaking various setting or modify my code to enable any leak detection.

Take a look at the official blog post here - introducing RADStudio support - which also includes a quick nice video :).

What even more surprised me was the list of known leaks - that by default is ignored coming from various internal parts of Windows - no wonder you need to restart your Windows once in a while - try to disable this option - very educating :)

The tool either works within the IDE, enabling you to jump to the line in the source code that causes the issues found, or by running as a standalone application and just pointing to your executable, comparing the before and after allocation "leftovers" I guess - by hooking into resource allocations and deallocations.

The last option might be helpful if you are embedding something like EurekaLog into your program, and it tries to do its thing while Deleaker also tries to help out - just stepping on each others toes. I am sure that the people behind Deleaker are eager to improve the tool, and also circumvent this issue if possible.

I do also use things like EurekaLog - to gather exception logs and FastMMs ReportMemoryLeaksOnShutdown := True - and sometimes madExcept and AQTime - but do give Deleaker's 14 days trial version a spin - I am sure that Artem will be happy to help if any issues arises to make the product even better for RADStudio.

It should also be noted that updates are very frequent and support seems very responsive - and if you are also using other IDE's it is nice that the tool does support these directly.

Now I just need to see it also available inside GetIt :D

/Enjoy

No comments:

Post a Comment