Small Memory Leak in TBrushDialog
Small Memory Leak in TBrushDialog
The private procedure TBrushDialog.LStyleDrawItem calls GetInternalBrush, which creates a TBitmap object that is never freed.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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 |
Instructions - How to post in this forum |
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.
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.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi pemar13,
Thanks for the information, but in TeeChart Pro v8 VCL, version released earlier this week, this method contains this code snippet:
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.
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);
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 |
Instructions - How to post in this forum |