TeeChart v8.07 VCL memory leak in Chart.pas

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
tmueller
Newbie
Newbie
Posts: 5
Joined: Thu Jan 31, 2008 12:00 am

TeeChart v8.07 VCL memory leak in Chart.pas

Post by tmueller » Mon Jun 21, 2010 2:41 pm

Hello Steema

I found a little memory leek in Chart.pas, method TLegendSymbol.Draw.
The local variable "OldBrush" will never be released.

Code: Select all

Report FastMM Fulldebugmode
******************************

--------------------------------2010/6/21 16:14:11--------------------------------
A memory block has been leaked. The size is: 36

This block was allocated by thread 0x628, and the stack trace (return addresses) at the time was:
403402 [sys\system.pas][System][System.@GetMem][2654]
4045FB [sys\system.pas][System][System.TObject.NewInstance][8807]
4049CA [sys\system.pas][System][System.@ClassCreate][9472]
44403E [Graphics.pas][Graphics][Graphics.TBrush.Create][2191]
40BC89 [FastMM4][FastMM4.UpdateHeaderAndFooterCheckSums][4439]
77D6E9 [Chart.pas][Chart][Chart.TLegendSymbol.Draw][3815]
404A38 [sys\system.pas][System][System.@AfterConstruction][9520]
77D06C [Chart.pas][Chart][Chart.TCustomChart.DrawLegendShape][3589]
76B980 [TeEngine.pas][TeEngine][TeEngine.TChartSeries.DrawLegendShape][10097]
792E0C [Series.pas][Series][Series.TCustomBarSeries.DrawLegendShape][3885]
76BB85 [TeEngine.pas][TeEngine][TeEngine.TChartSeries.DrawLegend][10171]

The block is currently used for an object of class: TBrush

Code: Select all

Code (Chart.pas)
******************

procedure TLegendSymbol.Draw(AColor: TColor; const R:TRect);
var tmp       : TCanvas3D;
    tmpR      : TRect;
    OldBrush  : TBrush;
begin
  tmp:=Parent.Canvas;

  OldBrush:=TBrush.Create; //<-- Created but never deleted
  OldBrush.Assign(tmp.Brush);

  if FShadow.Visible and (FShadow.Size<>0) then
     FShadow.Draw(tmp,R);

  tmp.Brush.Assign(OldBrush);

  if not DefaultPen then  // 8.01
     tmp.AssignVisiblePen(Pen);

  if Gradient.Visible then
  begin
    Gradient.EndColor:=AColor;
    Gradient.Draw(tmp,R);
    tmp.Brush.Style:=bsClear;
  end
  else
  begin
    tmp.Brush.Color:=AColor;
  end;

  if tmp.Pen.Style<>psClear then
     tmp.Rectangle(R)
  else
  if tmp.Brush.Style<>bsClear then
  begin
    tmpR:=R;

    Inc(tmpR.Right);
    Inc(tmpR.Bottom);
    tmp.Rectangle(tmpR)
  end;
end;
May you could fix this for the next release?

With best regards
Tom Mueller

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

Re: TeeChart v8.07 VCL memory leak in Chart.pas

Post by Narcís » Mon Jun 21, 2010 2:57 pm

Hello Tom,

Yes, that was already fixed as explained here.
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

tmueller
Newbie
Newbie
Posts: 5
Joined: Thu Jan 31, 2008 12:00 am

Re: TeeChart v8.07 VCL memory leak in Chart.pas

Post by tmueller » Fri Jun 25, 2010 5:53 am

Thank you for your fast response.

Post Reply