Lazarus has some memleaks caused by the keyboard tables. I have tried to look into it,…
Vincent Snijders wrote 7 lines
Fixed
Marc

Mailing lists / lazarus / 2003-10
5 messages · 3 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Lazarus has some memleaks caused by the keyboard tables. I have tried to look into it,…
Fixed
Marc
Lazarus has some memleaks caused by the keyboard tables. I have tried to look into it,…
Hi everybody. :)
Well im trying to make the TTIMER comonent working but with not result. I find the problem in the timer, but i dont know how to fix.
In delphi this works fine....
USES
FORMS,INTERFACES,CLASSES,BUTTONS,STDCTRLS,CONTROLS,DIALOGS,ExtCtrls;
VAR
MAINFORM : TForm;
BUTTONTIMER : TButton;
TIMELABEL : TLabel;
TESTTIMERX : TTimer;
Procedure TESTTIMERX_ONTIMER(SENDER : TOBJECT);
Begin
TIMELABEL.Caption := 'Test';
Application.MessageBox('Test','test',1)
End;
Procedure BUTTONTIMER_ONCLICK(SENDER : TOBJECT);
Begin
If (BUTTONTIMER.Caption='Start') Then Begin
BUTTONTIMER.Caption := 'Stop';
TESTTIMERX.Interval := 2000;
TESTTIMERX.Enabled := TRUE;
End
Else Begin
BUTTONTIMER.Caption := 'Start';
TESTTIMERX.Enabled := FALSE;
End;
End;{************************************************
MAIN PROCEDURE
************************************************}
BEGIN
MAINFORM := TForm.Create(MAINFORM); MAINFORM.Caption := 'Timer Test';
MAINFORM.Width := 120;
MAINFORM.Height := 100;
BUTTONTIMER := TButton.Create(nil);
BUTTONTIMER.Caption := 'Start';
BUTTONTIMER.Top := 25;
BUTTONTIMER.OnClick := @BUTTONTIMER_ONCLICK;
BUTTONTIMER.Parent := MAINFORM;
TIMELABEL := TLabel.Create(nil);
TIMELABEL.Caption := 'Time';
TIMELABEL.AutoSize := TRUE;
TIMELABEL.Top := 5;
TIMELABEL.Left := 5;
TIMELABEL.Parent := MAINFORM;
TESTTIMERX := TTimer.Create(nil);
TESTTIMERX.Enabled := FALSE;
TESTTIMERX.Interval := 1000;
TESTTIMERX.OnTimer := @TESTTIMERX_ONTIMER;
MAINFORM.SHow;
END.Well i have an error when try to use this in fpc... then i cant use Timer ussing this way...
But theres another way thats works for me and is....
USES
FORMS,INTERFACES,CLASSES,BUTTONS,STDCTRLS,CONTROLS,DIALOGS,ExtCtrls;
TYPE
MAINFORMCLASS = Class(TForm)
Public
BUTTONTIMER : TButton;
TIMELABEL : TLabel;
TESTTIMER : TTimer;
Constructor Create(AOwner: TComponent); override;
End;
VAR
MAINFORM : MAINFORMCLASS;
procedure TESTTIMER_ONTIMER(SENDER : TOBJECT);
Begin
MAINFORM.TIMELABEL.Caption := 'Test';
Application.MessageBox('Test','test',1)
End;
Procedure BUTTONTIMER_ONCLICK(SENDER : TOBJECT);
Begin
If (MAINFORM.BUTTONTIMER.Caption='Start') Then Begin
MAINFORM.BUTTONTIMER.Caption := 'Stop';
MAINFORM.TESTTIMER.Interval := 2000;
MAINFORM.TESTTIMER.Enabled := TRUE;
End
Else Begin
MAINFORM.BUTTONTIMER.Caption := 'Start';
MAINFORM.TESTTIMER.Enabled := FALSE;
End;
End;
Constructor MAINFORMCLASS.Create(AOwner: TComponent);
Begin
Inherited Create(AOwner);
Caption := 'Timer Test';
Width := 120;
Height := 100;
BUTTONTIMER := TButton.Create(Self);
BUTTONTIMER.Caption := 'Start';
BUTTONTIMER.Top := 25;
BUTTONTIMER.OnClick := @BUTTONTIMER_ONCLICK;
BUTTONTIMER.Parent := MAINFORM;
TIMELABEL := TLabel.Create(Self);
TIMELABEL.Caption := 'Time';
TIMELABEL.AutoSize := TRUE;
TIMELABEL.Top := 5;
TIMELABEL.Left := 5;
TIMELABEL.Parent := MAINFORM;
TESTTIMER := TTimer.Create(Self);
TESTTIMER.Enabled := FALSE;
TESTTIMER.Interval := 1000;
TESTTIMER.OnTimer := @TESTTIMER_ONTIMER;
End;
BEGIN
Application.Initialize;
Application.CreateForm(MAINFORMCLASS , MAINFORM);
Application.Run;
END.Ussing this everything works fine.. minus the timer :( im ussing this way for every object and every works fine) now im trying to use time and theres the unic component thats not work ussing this way....
But not end... i have continued trying and when i have tested this one....
USES
FORMS,INTERFACES,CLASSES,BUTTONS,STDCTRLS,CONTROLS,DIALOGS,ExtCtrls;
TYPE
MAINFORMCLASS = Class(TForm)
Public
BUTTONTIMER : TButton;
TIMELABEL : TLabel;
TESTTIMER : TTimer;
procedure TESTTIMER_ONTIMER(SENDER : TOBJECT);
Constructor Create(AOwner: TComponent); override;
End;
VAR
MAINFORM : MAINFORMCLASS;
procedure MAINFORMCLASS.TESTTIMER_ONTIMER(SENDER : TOBJECT);
Begin
MAINFORM.TIMELABEL.Caption := 'Test';
Application.MessageBox('Test','test',1)
End;
Procedure BUTTONTIMER_ONCLICK(SENDER : TOBJECT);
Begin
If (MAINFORM.BUTTONTIMER.Caption='Start') Then Begin
MAINFORM.BUTTONTIMER.Caption := 'Stop';
MAINFORM.TESTTIMER.Interval := 2000;
MAINFORM.TESTTIMER.Enabled := TRUE;
End
Else Begin
MAINFORM.BUTTONTIMER.Caption := 'Start';
MAINFORM.TESTTIMER.Enabled := FALSE;
End;
End;
Constructor MAINFORMCLASS.Create(AOwner: TComponent);
Begin
Inherited Create(AOwner);
Caption := 'Timer Test';
Width := 120;
Height := 100;
BUTTONTIMER := TButton.Create(Self);
BUTTONTIMER.Caption := 'Start';
BUTTONTIMER.Top := 25;
BUTTONTIMER.OnClick := @BUTTONTIMER_ONCLICK;
BUTTONTIMER.Parent := MAINFORM;
TIMELABEL := TLabel.Create(Self);
TIMELABEL.Caption := 'Time';
TIMELABEL.AutoSize := TRUE;
TIMELABEL.Top := 5;
TIMELABEL.Left := 5;
TIMELABEL.Parent := MAINFORM;
TESTTIMER := TTimer.Create(Self);
TESTTIMER.Enabled := FALSE;
TESTTIMER.Interval := 1000;
TESTTIMER.OnTimer := @TESTTIMER_ONTIMER;
End;
BEGIN
Application.Initialize;
Application.CreateForm(MAINFORMCLASS , MAINFORM);
Application.Run;
END.And voila This works!
But only and only the timer can not handle the address of the procedures outside of the main Class; Every component (I HAVE TESTED) can use this procedures, But Timer NOt :(
Theres a way to fix this problem in the main timer class?
Thanks....
Lazarus has some memleaks caused by the keyboard tables. I have tried to look into it,…
+ From: Vincent Snijders
+ Sent: vrijdag 24 oktober 2003 14:37
+ To:
+ Subject: [lazarus] Memleak caused by gtk keyboard tables +
+
+ Hi,
+
+ Lazarus has some memleaks caused by the keyboard tables. I have tried to
+ look into it, but it looks a bit to complicated to me. It is probably
+ not a critical bug. This table seems to be set up at application start,
+ used during the lifetime of the application, but is not (completely)
+ freed at the end. See heaptrc at the end of this mail for some details.
Hmm... now you mention it... I think I forgot to add the cleanup code.
Your right about the table, it is setup once and should have been cleanedup when the application stops.
The table itself might look complicated, but is in fact a 4 dimensional array to index cardinals splitted up in bytes.
I'll
Hi,
Lazarus has some memleaks caused by the keyboard tables. I have tried to look into it, but it looks a bit to complicated to me. It is probably not a critical bug. This table seems to be set up at application start, used during the lifetime of the application, but is not (completely) freed at the end. See heaptrc at the end of this mail for some details.
An other thing I noticed, is the comment with TGTKObject.AppInit. (is called by TApplication.Initialize which is typically after all finalization sections)
I don't understand this. What finalization sections are meant?
A third thing: The text in the BuildLazarusDialog is unreadable, because text and backgroud are black. Has anybody else noticed this?
Regards,
Vincent Snijders.
The heaptrc log is:
Heap dump by heaptrc unit
1248669 memory blocks allocated : 63022566/65816648 1248664 memory blocks freed : 63018982/65813064 5 unfreed memory blocks : 3584
True heap size : 24117248 (8240 used in System startup) True free heap : 24105104
Should be : 24105184
Call trace for block 0x405E4EE4 size 512
0x082B45CA KEYSYMTOVKEYARRAY, line 1249 of gtkproc.inc 0x082B55EE INITKEYBOARDTABLES, line 1854 of gtkproc.inc 0x0830B293 TGTKOBJECT__APPINIT, line 1472 of gtkobject.inc 0x082D781F TAPPLICATION__INITIALIZE, line 220 of ./include/application.inc 0x08361968 main, line 62 of lazarus.pp 0x08052A57
Call trace for block 0x405E4CA4 size 512
0x082B45CA KEYSYMTOVKEYARRAY, line 1249 of gtkproc.inc 0x082B55EE INITKEYBOARDTABLES, line 1854 of gtkproc.inc 0x0830B293 TGTKOBJECT__APPINIT, line 1472 of gtkobject.inc 0x082D781F TAPPLICATION__INITIALIZE, line 220 of ./include/application.inc 0x08361968 main, line 62 of lazarus.pp 0x08052A57
Call trace for block 0x405E4A64 size 512
0x082B45CA KEYSYMTOVKEYARRAY, line 1249 of gtkproc.inc 0x082B55EE INITKEYBOARDTABLES, line 1854 of gtkproc.inc 0x0830B293 TGTKOBJECT__APPINIT, line 1472 of gtkobject.inc 0x082D781F TAPPLICATION__INITIALIZE, line 220 of ./include/application.inc 0x08361968 main, line 62 of lazarus.pp 0x08052A57
Call trace for block 0x405E4624 size 1024
0x082B4574 KEYSYMTOVKEYARRAY, line 1239 of gtkproc.inc 0x082B55EE INITKEYBOARDTABLES, line 1854 of gtkproc.inc 0x0830B293 TGTKOBJECT__APPINIT, line 1472 of gtkobject.inc 0x082D781F TAPPLICATION__INITIALIZE, line 220 of ./include/application.inc 0x08361968 main, line 62 of lazarus.pp 0x08052A57
Call trace for block 0x405E41E4 size 1024
0x082B451A KEYSYMTOVKEYARRAY, line 1229 of gtkproc.inc 0x082B55EE INITKEYBOARDTABLES, line 1854 of gtkproc.inc 0x0830B293 TGTKOBJECT__APPINIT, line 1472 of gtkobject.inc 0x082D781F TAPPLICATION__INITIALIZE, line 220 of ./include/application.inc 0x08361968 main, line 62 of lazarus.pp 0x08052A57
Regards,
Vincent Snijders
I doubt it. For the following reasons:
* In all examples you are mixing regular procedure types and method types. That doesn't work (also not in Delphi)
* In the first example Mainform is it's own Owner. Or worse the mainform var is uninitialized.
In order to use events you *need* method types.
To keep your app running you need application.run.
So for both Delphi and Lazarus you should use Example 2 with a little modification. Both TESTTIMERX_ONTIMER and BUTTONTIMER_ONCLICK need to be a member of MAINFORMCLASS.
That is partially what you have done in example 3.
I tried it and it works, however it is a bit difficult to stop the timer.
Marc
**********
Example 1
**********
**********
Example 2
**********
**********
Example 3
**********