Page 1 of 1

Not reporting leaks

Posted: Tue Nov 10, 2020 9:59 am
by rsassen
Hi,

I'm trying to figure out why my large project does not report memory leaks (C++ Builder Sydney R1; madCollection 2.8.9.1; VCL application (converted from earlier C++ Builder version); legacy compiler; mostly statically linked; dynamic RTL; > 800 units, the resulting exe is 42 Mb, the tds file is 213 Mb). Things I have checked:
  • In the madExcept settings leak reporting is on.
  • madExcept is linked into the application (madBasic_.lib, madDisAsm_.lib, madExcept_.lib).
  • madExcept32.dll is present in the folder where the exe is. (note: DLL file properties report version 4.0.6.0, which is the same as my earlier version of madExcept. But the file size is 970.560 bytes, which differs from my earlier version of madExcept)
  • No message "Well done = No leaks found" either.
  • When I manually call Madexcept::StartLeakChecking soon after the start of the application, it does report leaks when the application exits. But I'd rather have leak checking started immediately when starting the application.
  • A small sample application compiled in the same IDE *does* report leaks.
Do you have any suggestion as where to look for the reason no leaks are reported? E.g. includes/links to check, any (debug) output/logging created during compile I could check? I've had a look at the contents of madExceptWizard.txt, but I'm not sure what to look for.

Hope you can help!

Re: Not reporting leaks

Posted: Wed Nov 11, 2020 8:01 pm
by madshi
You can check out the RCDATA\MADEXCEPT resource in your compiled EXE file, using the freeware "Resource Hacker". Does it say "ReportLeaks = False" or "ReportLeaks = True"?

Re: Not reporting leaks

Posted: Thu Nov 12, 2020 8:56 am
by rsassen
I cannot find RCDATA\MADEXCEPT , I think you mean RCDATA\TMADEXCEPT (starting with a "T")?

That one says Enabled = True, ReportLeaks = True.

Re: Not reporting leaks

Posted: Thu Nov 12, 2020 11:50 am
by madshi
Oops yes, that's the one I meant.

Hmmmmm... Does leak reporting fail both when running from inside and outside the IDE?

Re: Not reporting leaks

Posted: Thu Nov 12, 2020 12:57 pm
by rsassen
Yes, also when running outside the IDE, leaks are not reported unless I call Madexcept::StartLeakChecking myself after starting the application.

Re: Not reporting leaks

Posted: Thu Nov 12, 2020 1:16 pm
by madshi
That's really weird. The only thing coming to my mind would be for you to add madExcept.pas and mad.inc into your project, so they're actually compiled into your EXE file, instead of using the precompiled DCU/OBJ files that shipping with madExcept. This way you can actually set breakpoints in madExcept.pas to check what's going on.

Re: Not reporting leaks

Posted: Thu Nov 12, 2020 3:27 pm
by rsassen
Thanks, I'll give it a try compiling madExcept.pas into my project.
I'll let you know tomorrow.

Re: Not reporting leaks

Posted: Fri Nov 13, 2020 10:29 am
by rsassen
Thanks to your suggestions I've found the issue in my code. After compiling madExcept.pas into my application, I now got an access violation at the startup of my application, which pointed me to a problem in my code. By some coincidence this issue manifested itself before not with an access violation, but by interfering with the proper working of leak checking in madExcept. After fixing this problem and removing madExcept.pas from my project again, madExcept reports leaks as expected.

Thanks for the support, it is much appreciated!

Re: Not reporting leaks

Posted: Fri Nov 13, 2020 10:36 am
by madshi
Sounds like a very weird problem, to stop leak reporting from working. Glad you found it! :D