我需要激活ReportMemoryLeaksOnShutdown
功能,以报告我的应用程序的内存泄漏情况,但仅在调试模式下(当Delphi IDE正在运行时)。我该怎么做?
我需要激活ReportMemoryLeaksOnShutdown
功能,以报告我的应用程序的内存泄漏情况,但仅在调试模式下(当Delphi IDE正在运行时)。我该怎么做?
如果您指的是使用Debug构建配置(D2007+)编译时的“调试模式”,则已定义DEBUG符号,因此即使在运行时不在调试器中,也可以激活ReportMemoryLeaksOnShutdown:
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutdown := True;
{$ENDIF}
如果你想只在调试器存在时运行,看一下RRUZ的答案
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutDown := IsDebuggerPresent();
{$ENDIF}
如果您没有使用古老版本的Delphi并且在Windows 2000及更高版本上工作,则该函数应已在Windows单元中声明。
function IsDebuggerPresent: LongBool; stdcall;
function IsDebuggerPresent; external kernel32 name 'IsDebuggerPresent';
- Reversed Engineer
DebugHook
相关的愚蠢警告,{$WARN SYMBOL_PLATFORM OFF}
。 - jasonpenny