I need to activate the ReportMemoryLeaksOnShutdown functionality to report the memory leaks of my application, but only under debug mode (when the Delphi IDE is
ReportMemoryLeaksOnShutdown
try using the DebugHook variable
ReportMemoryLeaksOnShutdown:=DebugHook<>0;