delphi 如何在Windows中调试在Apache中运行的Embarcadero Rad Server中使用的BPL文件中的内存泄漏

jk9hmnmh  于 2023-05-06  发布在  Windows
关注(0)|答案(1)|浏览(197)

我需要帮助来定位在Windows上的Apache中运行的Rad Server中使用的端点资源文件中的内存泄漏。我相信FastMM是内置在 Delphi (我正在使用),但我不确定如何启用它,甚至如何从它获得输出。我能找到的所有指令都说要在DPR的begin部分包含ReportMemoryLeaksOnShutdown := true,但由于这只是一个BPL文件,我不确定它在哪里。此外,当应用程序关闭时,似乎会显示一个对话框,但由于这是在Apache中运行的,数据会在哪里呢?
是否有其他工具可以/应该使用,而不是FastMM?
任何帮助将不胜感激,如果我错过了我的问题中的任何重要信息,请让我知道。谢谢大家。

kyxcudwk

kyxcudwk1#

我们使用FastMM的下载版本。您需要添加FastMM单元作为第一个包含的单元。此外,请确保FastMM Debug dll位于apache文件夹中。
然后,您可以更改FastMM.inc文件,使其反映您的需要。我们使用以下设置(基于原始文件,但从评论中剥离...)-当然,您可以在这里更改设置,例如。在您的情况下,可能需要“UseRuntimePackages”选项:

{$Message Warn 'Debug memory manager configuration. Do not use in production'}

{$define Align16Bytes}
{$define UseCustomFixedSizeMoveRoutines}
{$define UseCustomVariableSizeMoveRoutines}
{.$define InstallOnlyIfRunningInIDE}
{.$define NeverUninstall}
{.$define UseRuntimePackages}
{$define AssumeMultiThreaded}
{.$define NeverSleepOnThreadContention}
{.$define UseSwitchToThread}
{.$define NoDebugInfo}
{$define NoMessageBoxes}
{$define UseOutputDebugString}
{$define ASMVersion}
{$define CheckHeapForCorruption}
{$define DetectMMOperationsAfterUninstall}
{$define FullDebugMode}
  {$define RawStackTraces}
  {$define CatchUseOfFreedInterfaces}
  {$define LogErrorsToFile}
  {$define LogMemoryLeakDetailToFile}
  {$define ClearLogFileOnStartup}
  {.$define LoadDebugDLLDynamically}
    {.$define DoNotInstallIfDLLMissing}
  {$define AlwaysAllocateTopDown}
  {.$define DisableLoggingOfMemoryDumps}
  {$define SuppressFreeMemErrorsInsideException}
  {.$define FullDebugModeCallBacks}

{$define EnableMemoryLeakReporting}

  {$define HideExpectedLeaksRegisteredByPointer}
  {.$define RequireIDEPresenceForLeakReporting}
  {$define RequireDebugInfoForLeakReporting}
  {.$define ManualLeakReportingControl}
  {.$define HideMemoryLeakHintMessage}
{.$define EnableMMX}
  {$define ForceMMX}
{$define ShareMM}
  {$define ShareMMIfLibrary}
{$define AttemptToUseSharedMM}
{.$define ClearMemoryBeforeReturningToOS}
{.$define AlwaysClearFreedMemory}
{.$define LogLockContention}
{.$define FullDebugModeInIDE}
{.$define FullDebugModeWhenDLLAvailable}
{$ifdef Release}
  {Specify the options you use for release versions below}
  {.$undef FullDebugMode}
  {.$undef CheckHeapForCorruption}
  {.$define ASMVersion}
  {.$undef EnableMemoryLeakReporting}
  {.$undef UseOutputDebugString}
{$else}
  {Specify the options you use for debugging below}
  {.$define FullDebugMode}
  {.$define EnableMemoryLeakReporting}
  {.$define UseOutputDebugString}
{$endif}

{.$define borlndmmdll}
{.$define dllforide}
{.$define debugdll}
{$ifdef borlndmmdll}
  {$define AssumeMultiThreaded}
  {$undef HideExpectedLeaksRegisteredByPointer}
  {$undef RequireDebuggerPresenceForLeakReporting}
  {$undef RequireDebugInfoForLeakReporting}
  {$define DetectMMOperationsAfterUninstall}
  {$undef ManualLeakReportingControl}
  {$undef ShareMM}
  {$undef AttemptToUseSharedMM}
  {$ifdef dllforide}
    {$define NeverUninstall}
    {$define HideMemoryLeakHintMessage}
    {$undef RequireIDEPresenceForLeakReporting}
    {$ifndef debugdll}
      {$undef EnableMemoryLeakReporting}
    {$endif}
  {$else}
    {$define EnableMemoryLeakReporting}
    {$undef NeverUninstall}
    {$undef HideMemoryLeakHintMessage}
    {$define RequireIDEPresenceForLeakReporting}
  {$endif}
  {$ifdef debugdll}
    {$define FullDebugMode}
    {$define RawStackTraces}
    {$undef CatchUseOfFreedInterfaces}
    {$define LogErrorsToFile}
    {$define LogMemoryLeakDetailToFile}
    {$undef ClearLogFileOnStartup}
  {$else}
    {$undef FullDebugMode}
  {$endif}
{$endif}

{$ifdef BCB}
  {$ifdef CheckHeapForCorruption}
    {$define PatchBCBTerminate}
  {$else}
    {$ifdef DetectMMOperationsAfterUninstall}
      {$define PatchBCBTerminate}
    {$else}
       {$ifdef EnableMemoryLeakReporting}
         {$define PatchBCBTerminate}
       {$endif}
    {$endif}
  {$endif}

  {$ifdef PatchBCBTerminate}
    {$define CheckCppObjectType}
    {$undef CheckCppObjectTypeEnabled}

    {$ifdef CheckCppObjectType}
      {$define CheckCppObjectTypeEnabled}
    {$endif}

    {Turn off "CheckCppObjectTypeEnabled" option if neither "CheckHeapForCorruption"
     option or "EnableMemoryLeakReporting" option were defined.}
    {$ifdef CheckHeapForCorruption}
    {$else}
      {$ifdef EnableMemoryLeakReporting}
      {$else}
        {$undef CheckCppObjectTypeEnabled}
      {$endif}
    {$endif}
  {$endif}
{$endif}

相关问题