Page 1 of 1

GDI resource leak in v2010

Posted: Mon May 17, 2010 7:03 am
by 16556135
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?

Re: GDI resource leak in v2010

Posted: Mon May 17, 2010 9:08 am
by narcis
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.

Re: GDI resource leak in v2010

Posted: Mon May 17, 2010 10:24 am
by 16556135
I've attached a demo project and two screenshots. One right after the app start, the other after 10 clicks on the button.

Re: GDI resource leak in v2010

Posted: Mon May 17, 2010 11:24 am
by narcis
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

Re: GDI resource leak in v2010

Posted: Mon May 17, 2010 12:03 pm
by 16556135
Thanks for the quick response.
Works! :-)

Re: GDI resource leak in v2010

Posted: Mon May 17, 2010 12:06 pm
by narcis
Hi Kubach,

You're very welcome :!:

I have added the fix for next 2010 maintenance release too.