lazarus 检测内存泄漏


lazarus 检测内存泄漏步骤:
1、打开 Lazarus project
2、Porject Options–>compiler Options–>Debugging–>勾上Use Heaptrc unit(check for mem0leaks))gh)
警告:请勿手动添加Heaptrc单元!

lazarus 检测内存泄漏

程序退出时会检测内存泄漏情况:

lazarus 检测内存泄漏

3、仅显示内存泄漏的设置方法:
      在Project Source添加

{$if declared(UseHeapTrace)}
GlobalSkipIfNoLeaks := True; // supported as of debugger version 3.2.0
{$endIf}

完成的Project Source:

program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  {$IFDEF HASAMIGA}
  athreads,
  {$ENDIF}
  SysUtils,
  Interfaces, // this includes the LCL widgetset
  Forms, Unit1, pgprovider10, unidac10, sbridge10, dacsbridge10
  { you can add units after this };

{$R *.res}

begin
  {$if declared(UseHeapTrace)}
  GlobalSkipIfNoLeaks := True; // supported as of debugger version 3.2.0
  {$endIf}
  RequireDerivedFormResource:=True;
  Application.Scaled:=True;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

详见:https://wiki.freepascal.org/heaptrc

原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/271553.html

(0)
上一篇 2022年7月4日
下一篇 2022年7月4日

相关推荐

发表回复

登录后才能评论