Forum Discussion

easyboy1's avatar
11 years ago

Font leak?

I use aqtime std in xe2 and it reported:


Module Name Class Name Object Name Get#

PROJECT1.EXE Font Font.128 1



my simple project here:

procedure TForm1.Button1Click(Sender: TObject);

var DC:HDC;FontObj:HFont;

begin

DC:=Self.Canvas.Handle;

FontObj:=CreateFont(-MulDiv(7,GetDeviceCaps(DC,LOGPIXELSY),72),0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH,PChar('Arial'));

If FontObj<>0 Then begin

DeleteObject(SelectObject(DC,FontObj));

end;

end;



is it memory leak? i've been deleted the old font using DeleteObject,why it reports the leak message?thx a lot!

1 Reply

  • aqAnt's avatar
    aqAnt
    SmartBear Alumni (Retired)


    Hi,



    Indeed, your code produces a resource leak that can be detected with AQtime's Resource profiler. To avoid the leak, you need to delete the created font: