系统相关
首页 > 系统相关> > lazarus 检测内存泄漏

lazarus 检测内存泄漏

作者:互联网

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

标签:泄漏,--,supported,Application,lazarus,内存,True
来源: https://www.cnblogs.com/qiufeng2014/p/16443224.html