A simple test form, with a label and a timer with interval set to 5:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.Caption:=IntToStr(GetMsCount);
counter:=counter+1;
end;
with gtk1 memory usage is constant, while under gtk2 it grows
continuosly. Heaptrc report no leaks (probably the memory is freed when
the program ends, but that's of no use to me since my program is
supposed to run forever), valgrind chokes on it.
With the following code (to adapt the size of the text to the available
space) memory usage grows an order of magnitude faster (again, with gtk1
it is stable)
procedure TForm1.Timer1Timer(Sender: TObject);
var
DC : hDC;
OldFont: HGDIOBJ;
AFont: TFont;
NeededWidth: Integer;
xSize : tSize;
t: string;
begin
t:=IntToStr(GetMsCount);
AFont:=TFont.Create;
AFont.Assign(Label1.Font);
AFont.Size:=100;
DC := GetDC(Handle);
try
OldFont:=SelectObject(DC, AFont.Handle);
GetTextExtentPoint(DC, PChar(t), Length(t), xSize);
SelectObject(DC, OldFont);
NeededWidth:=xSize.cx;
if NeededWidth>Label1.Width then
begin
AFont.Size:=100*Label1.Width div NeededWidth -5;
end;
finally
ReleaseDC(Handle, DC);
Label1.Font.Size:=Afont.Size;
Label1.Caption:=t;
AFont.Free;
end;
end;
Bye
--
Luca
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives