delphifastmm

FastMM showing error in release builds when closing application


I have some customers reporting an error sometimes when closing my applications:

enter image description here

This is slightly surprising due to:

  1. GetMEM call after FastMM is unsinstalled is a bit weird (user reports he is using commandline functionality of my application, so I will try investigate that, but I do not call anything after an application is terminated. But okay, something worth investigating)

  2. I am using release mode settings, so howcome FastMM shows an error message? That is the most important question for me...

These are the defines I am using for release builds:

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

The application is multhreaded, but does not share memory manager with dlls or similar


Solution

  • According to the FastMM source code, you can do:

    {$undef DetectMMOperationsAfterUninstall}
    

    To avoid this error message.

    Excerpt from the source code:

    {$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}