Не могу разобраться (лыжи не едут)...
Пустой примитивный поток
Пустая форма и утечка памяти...
Поток:
- Код: Выделить всё
unit dirmon;
{$mode ObjFPC}{$H+}
interface
uses Classes, Windows, SysUtils;
type
{ TChangeMonitor }
TChangeMonitor = class(TThread)
private
public
constructor Create(ASuspended: boolean);
destructor destroy; override;
protected
procedure Execute; override;
end;
implementation
constructor TChangeMonitor.Create(ASuspended: boolean);
begin
inherited Create(ASuspended);
FreeOnTerminate:=true;
end;
destructor TChangeMonitor.destroy;
begin
inherited destroy;
end;
procedure TChangeMonitor.Execute;
begin
end;
end.
Форма:
- Код: Выделить всё
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, dirmon;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
tmp:TChangeMonitor;
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
tmp:=TChangeMonitor.Create(true);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
tmp.Terminate;
end;
end.
Heap:
E:\Code\LCommander\threadsTest\test.exe
Heap dump by heaptrc unit of E:\Code\LCommander\threadsTest\test.exe
940 memory blocks allocated : 1447336/1448112
938 memory blocks freed : 1447240/1448016
2 unfreed memory blocks : 96
True heap size : 1540096 (160 used in System startup)
True free heap : 1539392
Should be : 1539456
Call trace for block $00000000016AE690 size 24
$000000010001180F
$000000010001388E
$000000010001315F
$000000010004B990
$000000010004BC88
$0000000100034E6A Create, line 26 of dirmon.pas
$0000000100034DC7 FormCreate, line 34 of unit1.pas
$00000001000239A3 DOCREATE, line 922 of include/customform.inc
$000000010002180E AFTERCONSTRUCTION, line 77 of include/customform.inc
$00000001000299BF CREATE, line 3218 of include/customform.inc
$0000000100031C28 CREATEFORM, line 2243 of include/application.inc
$0000000100002CA0 $main, line 23 of test.lpr
$0000000100002CC6
$00000001000175C0
$0000000100002C2B
$00007FFC9487259D
Call trace for block $0000000001614AD0 size 72
$0000000100011729
$000000010000E188
$0000000100034E3A Create, line 25 of dirmon.pas
$0000000100034DC7 FormCreate, line 34 of unit1.pas
$00000001000239A3 DOCREATE, line 922 of include/customform.inc
$000000010002180E AFTERCONSTRUCTION, line 77 of include/customform.inc
$00000001000299BF CREATE, line 3218 of include/customform.inc
$0000000100031C28 CREATEFORM, line 2243 of include/application.inc
$0000000100002CA0 $main, line 23 of test.lpr
$0000000100002CC6
$00000001000175C0
$0000000100002C2B
$00007FFC9487259D
$00007FFC9614AF38
$0000000100002C2B
$00007FFC9487259D
WIN11_64 PRO
Lazarus 3.8 32/64
FPC 3.2.2