Memory leaks for TThread and CheckSynchronize
Original Reporter info from Mantis: hnb
-
Reporter name: Maciej Izak
Original Reporter info from Mantis: hnb
- Reporter name: Maciej Izak
Description:
CheckSynchronize won't works correctly with threads. This simple program willl cause 2 memory leaks (while in Delphi all is ok). Maybe bug is related to #29470 (closed):
======
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF FPC}heaptrc,{$ENDIF}Classes;
type
TA = class(TThread)
private
F: TA;
protected
procedure Execute; override;
public
constructor Create(AObj: TA);
end;
{ TA }
procedure TA.Execute;
begin
if F <> nil then
F.Free
else
Suspend;
end;
constructor TA.Create(AObj: TA);
begin
if AObj <> nil then
FreeOnTerminate:=true;
F:=AObj;
inherited Create(false);
end;
var
A1: TA;
A2: TA;
begin
{$IFDEF FPC}
SetHeapTraceOutput('thread.log');
{$ELSE}
ReportMemoryLeaksOnShutdown:=true;
{$ENDIF}
A1 := TA.Create(nil);
A2 := TA.Create(A1);
WriteLn('Press [enter] to continue');
Readln;
A2.Terminate;
CheckSynchronize(1);
end.
Mantis conversion info:
- Mantis ID: 31987
- Platform: Windows 7
- Version: 3.1.1