秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

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

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

posted on 2022-07-04 15:51  秋·风  阅读(416)  评论(0编辑  收藏  举报