Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-09

TFPTimer memory leak

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Okoba

Hi,

I have a memory leak problem with TFPTimer and I think I'm missing something. It happens randomly and not always. Tested with Lazarus 1.8.4 and FPC 3.0.4 and FPC 3.1.1 on last updated version of Windows 10 with Debug build mode and it writes a memory leak lead to "Driver.Enabled := True;" Can anyone help me?

procedure TForm1.FormCreate(Sender: TObject);
begin
  Driver := TFPTimer.Create(Self);
  Driver.Interval := 33;
  Driver.OnTimer := @DriveOnTimer;
  Driver.Enabled := True;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
  Driver.Enabled := False;
  Driver.Free;
end;
procedure TForm1.DriveOnTimer(Sender: TObject);
begin
  Caption := TimeToStr(Now);
end;

Heap dump by heaptrc unit
974 memory blocks allocated : 1698252/1700016
972 memory blocks freed : 1698116/1699880
2 unfreed memory blocks : 136
True heap size : 753664
True free heap : 753056
Should be : 753272
Call trace for block $00000000012AE390 size 16
$0000000100010CEB
$0000000100012D87
$0000000100012608
$000000010018985D
$0000000100189C59
$0000000100189622
$0000000100189551
$000000010003AA64 line 39 of unit1.pas
Call trace for block $000000000129E7B0 size 120
$0000000100010C12
$000000010000DF57
$00000001001897FA
$0000000100189C59
$0000000100189622
$0000000100189551
$000000010003AA64 line 39 of unit1.pas
$0000000100020591 line 939 of include/customform.inc

Reply by email

Okoba
to Okoba

In this topic BrunoK said if we add Application.ProcessMessages; before Driver.Free it prevents the memory leak. But I want to know if this is a good solution for it and if I faced a bug.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Okoba wrote 50 lines
Hi, I have a memory leak problem with TFPTimer and I think I'm missing something. It happens randomly and not always. Tested with Lazarus 1.8.4 and FPC 3.0.4 and FPC 3.1.1 on last updated version of Windows 10 with Debug build mode and it writes a memory leak lead to "Driver.Enabled := True;" Can anyone help me? procedure TForm1.FormCreate(Sender: TObject); begin Driver := TFPTimer.Create(Self); Driver.Interval := 33; Driver.OnTimer := @DriveOnTimer; Driver.Enabled := True; end; procedure TForm1.FormDestroy(Sender: TObject); begin Driver.Enabled := False; Driver.Free; end; procedure TForm1.DriveOnTimer(Sender: TObject); begin Caption := TimeToStr(Now); end; Heap dump by heaptrc unit 974 memory blocks allocated : 1698252/1700016 972 memory blocks freed : 1698116/1699880 2 unfreed memory blocks : 136 True heap size : 753664 True free heap : 753056 Should be : 753272 Call trace for block $00000000012AE390 size 16 $0000000100010CEB $0000000100012D87 $0000000100012608 $000000010018985D $0000000100189C59 $0000000100189622 $0000000100189551 $000000010003AA64 line 39 of unit1.pas Call trace for block $000000000129E7B0 size 120 $0000000100010C12 $000000010000DF57 $00000001001897FA $0000000100189C59 $0000000100189622 $0000000100189551 $000000010003AA64 line 39 of unit1.pas $0000000100020591 line 939 of include/customform.inc

Reply by email