Small Memory Leak in TBrushDialog

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
pemar13
Newbie
Newbie
Posts: 7
Joined: Wed Dec 15, 2004 5:00 am

Small Memory Leak in TBrushDialog

Post by pemar13 » Mon Jun 18, 2007 10:53 am

The private procedure TBrushDialog.LStyleDrawItem calls GetInternalBrush, which creates a TBitmap object that is never freed.

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

Post by Narcís » Mon Jun 18, 2007 3:24 pm

Hi pemar13,

This is a function that returns an object. Who makes the call has to free the object and this is already done everywhere this method is called.

Anyway, if you think you have found a memory leak in TeeChart please send us a simple example project we can run "as-is" to reproduce the problem here and we will try it with a profiler.

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

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

pemar13
Newbie
Newbie
Posts: 7
Joined: Wed Dec 15, 2004 5:00 am

Post by pemar13 » Fri Jun 22, 2007 12:35 pm

Hi Narcis,

Yes, TBrushDialog.GetInternalBrush is a function that returns an object that has to be freed by the caller.

No, this is NOT done everywhere this method is called.

If you take a look at TBrushDialog.LStyleDrawItem, line 296 of the 7.11 version of TeeBrushDlg.pas you will find the code

StretchDraw(Rect,GetInternalBrush(Index-8))

which clearly cannot free the object created by GetInternalBrush.

Of course, I could spend the time to create and upload a simple example project that illustrates the memory leak so that you can run a profiler.
In this obvious case, however, I believe that you by simply taking a look at the mentioned code will come to the same conclusion as me, saving both my time and yours.

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

Post by Narcís » Fri Jun 22, 2007 1:59 pm

Hi pemar13,

Thanks for the information, but in TeeChart Pro v8 VCL, version released earlier this week, this method contains this code snippet:

Code: Select all

      if Index>7 then
      begin
        tmp:=GetInternalBrush(Index-8);
        try
          StretchDraw(Rect,tmp);
        finally
          tmp.Free;
        end;
      end
      else
         FillRect(Rect);
This mean the returned object from GetInternalBrush is assigned to tmp variable and this is already freed at tmp.Free call.

You may want to implement something similar in your v7 sources.
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

pemar13
Newbie
Newbie
Posts: 7
Joined: Wed Dec 15, 2004 5:00 am

Post by pemar13 » Mon Jun 25, 2007 8:00 am

Thanks Narcis, please see new post about TeeChart 8 bugfixes

Post Reply