GDI resource leak in v2010

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Kubach
Newbie
Newbie
Posts: 6
Joined: Tue May 11, 2010 12:00 am

GDI resource leak in v2010

Post by Kubach » Mon May 17, 2010 7:03 am

Hi,
I'm using the v2010 version and it seems, I’ve encountered a GDI resource problem when using GDI+.
When I set the transparency of say a TBarSeries and use TTeeGDIPlus to render it, I’ve noticed that the number of GDI handles steadily increases whenever a repaint occurs.

I’ve tried to find out why and noticed a difference between the TeCanvas implementation and the GDIPlusCanvas one:

While in TeCanvas the Blend is freed:
procedure TTeeCanvas.EndBlending(Blend:TTeeBlend);
begin
Blend.DoBlend(ITransp);
Blend.Free;
end;

it isn’t in the GDI+ one:
procedure TGDIPlusCanvas.EndBlending(Blend:TTeeBlend);
begin
Transparency:=255;
end;

Could this be the reason?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: GDI resource leak in v2010

Post by Narcís » Mon May 17, 2010 9:08 am

Hi Kubach,

I'm not even sure there's a leak here. Could you please elaborate on why do you think there's a link and how can we reproduce that?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Kubach
Newbie
Newbie
Posts: 6
Joined: Tue May 11, 2010 12:00 am

Re: GDI resource leak in v2010

Post by Kubach » Mon May 17, 2010 10:24 am

I've attached a demo project and two screenshots. One right after the app start, the other after 10 clicks on the button.
Attachments
ChartGDIPlusLeak.7z
(107.48 KiB) Downloaded 222 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: GDI resource leak in v2010

Post by Narcís » Mon May 17, 2010 11:24 am

Hi Kubach,

Thanks for your feedback. I could reproduce the issue and it seems adding Blend.Free at EndBlending solves the problem:

Code: Select all

procedure TGDIPlusCanvas.EndBlending(Blend:TTeeBlend);
begin
  Transparency:=255;
  Blend.Free;
end
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Kubach
Newbie
Newbie
Posts: 6
Joined: Tue May 11, 2010 12:00 am

Re: GDI resource leak in v2010

Post by Kubach » Mon May 17, 2010 12:03 pm

Thanks for the quick response.
Works! :-)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: GDI resource leak in v2010

Post by Narcís » Mon May 17, 2010 12:06 pm

Hi Kubach,

You're very welcome :!:

I have added the fix for next 2010 maintenance release too.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply