Memory leak detection with FastMM and exit code

I have an idea to enable FastMMs memleakreporting in nightly auto build. Of course, the message should be disabled. The simplest would probably be if the application exit code were> 0, if there was memleak. I did a quick test, and exitcode is 0 with memleak and FastMM.

So my question is how to determine if FastMM has memleak for setting exit code?

+3
source share
2 answers

For my previous Delphi project, I used MemCheck. He created a text log file with all the leaks detected. I like this reporting method, and I see that FastMM has the ability to create such a file: in FastMM4Options.incthere LogErrorsToFile. So you need to check the log file, not check the exit code.

+4
source

I changed the "CheckBlocksOnShutdown procedure (ACheckForLeakedBlocks: Boolean);" set an exit code for my current client, so I could easily check for DUnit if the spawned process had a memory leak. I added a line at the end of the procedure:

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

Source: https://habr.com/ru/post/1728266/


All Articles