【问题标题】:Detect memory leaks with FastMM and the exitcode使用 FastMM 和 exitcode 检测内存泄漏
【发布时间】:2010-01-13 08:30:07
【问题描述】:

我有一个想法,可以在夜间自动构建中启用 FastMMs memleakreporting。消息框当然应该被禁用。 如果存在内存泄漏,最简单的可能是应用程序退出代码 > 0。我做了一个快速测试,退出代码为 0,带有 memleak 和 FastMM。

所以我的问题是如何检测 FastMM 中是否存在 memleak 来设置退出代码?

【问题讨论】:

    标签: delphi memory-leaks fastmm


    【解决方案1】:

    对于我之前的 Delphi 项目,我使用了 MemCheck。它创建了包含它检测到的所有泄漏的文本日志文件。我喜欢这种报告方式,我看到 FastMM 可以选择创建这样的文件:在FastMM4Options.inc 中有LogErrorsToFile。这样你需要检查日志文件而不是检查退出代码。

    【讨论】:

    • 那当然是一种方式。我使用 Finalbuilder,所以应该很容易检测到该 memleak 文件。
    【解决方案2】:

    我修改了“procedure CheckBlocksOnShutdown(ACheckForLeakedBlocks: Boolean);”让我当前的客户设置退出代码,因此如果生成的进程有内存泄漏,我可以轻松地检查 DUnit。 我在程序末尾添加了一行:

      ...
      {$ifdef UseOutputDebugString}
      OutputDebugStringA(LLeakMessage);
      {$endif}
      ExitCode := 1;     <-- added this one
      if Assigned(OnMessage) then
        OnMessage(LLeakMessage);
      ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多