【问题标题】:FastMM showing error in release builds when closing application关闭应用程序时,FastMM 在发布版本中显示错误
【发布时间】:2021-05-21 11:53:49
【问题描述】:

有些客户在关闭我的应用程序时有时会报告错误:

这有点令人惊讶,因为:

  1. 在卸载 FastMM 后调用 GetMEM 有点奇怪(用户报告他正在使用我的应用程序的命令行功能,所以我会尝试对此进行调查,但在应用程序终止后我不会调用任何内容。但是好的,值得调查的事情)

  2. 我正在使用发布模式设置,那么 FastMM 怎么会显示错误消息? 这对我来说是最重要的问题...

这些是我用于发布构建的定义:

  {$undef FullDebugMode}
  {$undef EnableMemoryLeakReporting}
  {$undef CheckHeapForCorruption}
  {$undef UseOutputDebugString}
  {$undef RawStackTraces}
  {$undef LogErrorsToFile}
  {$undef LogMemoryLeakDetailToFile}
  {$undef ClearLogFileOnStartup}
  {$undef HideExpectedLeaksRegisteredByPointer}
  {$define ASMVersion}
  {$define AssumeMultiThreaded}

应用程序是多线程的,但不与 dll 或类似的共享内存管理器

【问题讨论】:

  • 可能是在应用程序终止时困扰您的挥之不去的线程。不看代码很难说...
  • 有什么办法可以防止FastMM显示错误信息?
  • 我会调查的。但我自己在 15 年多的时间里从未见过这个问题。但是,是的。但是,在发布版本中,我认为最好抑制任何错误。特别是如果在应用程序终止(并且所有内存释放回操作系统)时发生问题
  • 这确实表明您的程序某处存在缺陷

标签: delphi fastmm


【解决方案1】:

根据FastMM source code,你可以这样做:

{$undef DetectMMOperationsAfterUninstall}

为了避免这个错误信息。

摘自源代码:

{$ifdef DetectMMOperationsAfterUninstall}
{Invalid handlers to catch MM operations after uninstall}
function InvalidFreeMem(APointer: Pointer): {$ifdef fpc}NativeUInt{$else}Integer{$endif}; forward;
function InvalidGetMem(ASize: {$ifdef XE2AndUp}NativeInt{$else}{$ifdef fpc}NativeUInt{$else}Integer{$endif}{$endif}): Pointer; forward;
function InvalidReallocMem({$ifdef fpc}var {$endif}APointer: Pointer; ANewSize: {$ifdef XE2AndUp}NativeInt{$else}{$ifdef fpc}NativeUInt{$else}Integer{$endif}{$endif}): Pointer; forward;
function InvalidAllocMem(ASize: {$ifdef XE2AndUp}NativeInt{$else}{$ifdef fpc}NativeUint{$else}Cardinal{$endif}{$endif}): Pointer; forward;
function InvalidRegisterAndUnRegisterMemoryLeak(APointer: Pointer): Boolean; forward;
{$endif}

【讨论】:

  • 当它不回答 OP 问题时,它是如何被接受的?这是一种解决方法,而不是任何罪魁祸首的解决方案。
  • 它回答了 OP 最重要的问题,不是吗?
  • 它没有:问题是“怎么来的”,而您的解决方法是“避免它”。什么都没有回答,只是被压制了。我仍然会感兴趣为什么 FastMM 检测到这样的呼叫 - OP 无处要求简单地避免消息框。
  • 在我看来,发布模式下的 FastMM 不应显示错误消息,因此在这方面问题已得到解答。 “我正在使用发布模式设置,所以 FastMM 怎么会显示错误消息?” (如果应用程序无论如何都会被终止,所有内存都将被释放回操作系统......)但我当然会调查这个问题,但同时最终消费者对这样的对话框没有任何好处。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多