Avatar of fischermx
fischermxFlag for Mexico

asked on 

Checking for memory leaks in Delphi XE application


I was a long user of Memproof... correction I am still a user of Memproof, and I use it in two old applications I still maintain, one in Delphi 5 other in Delphi 7.

Now, I'm doing some weird pointer operations (weird cause I'm not an expert) in a new project I started in Delphi XE.
I compiled and try to run with Memproof and I get nothing... looks like memproof can't hook into this Delphi application.
I supose its simply because it was writing long before this particular Delphi version, it's just not prepared for that.

Now, I did some research and found recommendations for FastMM, and EurekaLog.... non of them look similar to memproof...
Well, first question here, are these the only two options? What else?

And next one, in this Delphi XE, it installed a version of AutomatedQA AQTime, and I remember I once used that for memory leaks when a contractor provide me a license of that for certain project. Now I look at what I have installed, and I not even know where to start, seems like this included version does not the memory leak checking thing... does it?






DelphiPascal

Avatar of undefined
Last Comment
fischermx
ASKER CERTIFIED SOLUTION
Avatar of samenglish
samenglish
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of fischermx
fischermx
Flag of Mexico image

ASKER


Well, the I was not looking for a nice GUI exactly, but with memproof I liked you can link the code and get a reference directly to the offending leak.


With FastMM all I got was a text file =) but well, I've just found one leak in my code and fixed it, but it is because it's a few dozens lines of code with more lines you'd get lost.

It just tells you the class name and the amount of leaks, so, for example, if you have an leak on a TList and have lots of that class in your code, how do you know which is the leaked one?
Avatar of samenglish
samenglish
Flag of Australia image


Another one I've used in the past is MadExcept http://www.madshi.net/   
It did the job for me at the time.

With FastMM, there are some special switches you need to set. I think what you really need is a good link that walks you through the process of using FastMM.

http://wiert.wordpress.com/2009/07/29/delphi-fastmm-using-fastmm4-for-debugging-your-memory-allocations-part-1-introduction/

However, if you're familiar with FastMM and you're having issues because it's Delphi XE then please let me know.
Avatar of fischermx
fischermx
Flag of Mexico image

ASKER

I am using MadExcept right now.
But it didn't report me any memory leak.

How, where, do I configure it for memory leak checks?
I'm using it just as an exception catcher.

Avatar of samenglish
samenglish
Flag of Australia image

MadExcept is just good at catching bad code, not necessarily memory leaks. Make sure you're on the latest version for XE support.

If you're serious about memory leaks I'd go with FastMM. You need to set FullDebugMode. (refer to link provided in previous post)

In your code, you need to make sure that every object you create at runtime will also be destroyed at runtime. So use this pattern repeatedly throughout your methods, and pass parameters by reference rather than have function return dynamically created objects (it makes it easier to see the obj being created, so that you remember to destroy it when it has served its purpose).

MyObj.Create
try
  // you code
finally
  MyObj.Free; // or FreeAndNil(MyObj);
end;
Avatar of samenglish
samenglish
Flag of Australia image

also here http://stackoverflow.com/questions/6075554/how-do-i-turn-on-off-fastmm-memory-leak-reporting-under-delphi-xe

NOTE: Delphi XE's integrated FastMM is not as powerful as the seperate FastMM download. The FastMM download is configurable for XE the same way it is done with earlier versions of Delphi (refer to link previously provided).
Avatar of fischermx
fischermx
Flag of Mexico image

ASKER

Thank you!

FastMM has been of great help.
Delphi
Delphi

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.

60K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo