开发者

Detect memory leaks with FastMM and the exitcode

开发者 https://www.devze.com 2022-12-16 01:15 出处:网络
I have an idea to enable FastMMs memleakreporting in the nightly automatic build. The messagebox should of course be disabled.

I have an idea to enable FastMMs memleakreporting in the nightly automatic build. The messagebox should of course be disabled. The simplest would probably be if the applications exitcode was > 0 if there was a memleak. I did a quick test and the exitcode was 0 with a memleak and FastMM.

So my question is how can I detect if there was a memleak in FastMM to s开发者_JS百科et the exitcode ?


For my previous Delphi project I used MemCheck. It created text log file with all leaks it detected. I like this way of reporting and I see that FastMM has option do create such file: in FastMM4Options.inc there is LogErrorsToFile. This way you need to check log file and not check exitcode.


I modified "procedure CheckBlocksOnShutdown(ACheckForLeakedBlocks: Boolean);" for my current customer to set the exitcode, so I could easily check in DUnit if a spawned process had a mem 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);
  ...
0

精彩评论

暂无评论...
验证码 换一张
取 消