Page 1 of 1

Memory leek using GDI instead of GDI+

Posted: Wed Oct 30, 2013 11:55 am
by 9339286
How to trigger the error:
1. Make a new VCL application
2. Drop a TChart component on the main form
3. Edit the TChart: Edit Chart->Chart->3D->render and select GDI instead of GDI+
4. Run the application and close it

using any debug-memory manager of your choice will show you the leek...

As far as I could trace the error it happens in:

Code: Select all

procedure TCustomTeePanel.CreateDefaultCanvas;
var t   : Integer;
    tmp,
    tmpClass : TCanvas3DClass;
begin
  tmpClass:=TTeeCanvas3D;

  if IDefaultCanvas<>'' then
     for t:=0 to TeeRenderClasses.Count-1 do
     begin
       tmp:={$IFNDEF D18}TCanvas3DClass{$ENDIF}(TeeRenderClasses[t]);

       if tmp.ClassName=IDefaultCanvas then
       begin
         tmpClass:=tmp;
         break;
       end;
     end;

  if (not Assigned(InternalCanvas)) or (tmpClass<>InternalCanvas.ClassType) then
  begin
    InternalCanvas:=tmpClass.Create;
    InternalCanvas.ReferenceCanvas:=FDelphiCanvas;
  end;
end;

Maybe the only thing to do, is to Free the InternalCanvas:

Code: Select all

  if (not Assigned(InternalCanvas)) or (tmpClass<>InternalCanvas.ClassType) then
  begin
    if Assigned(InternalCanvas) then
       InternalCanvas.Free;
    InternalCanvas:=tmpClass.Create;
    InternalCanvas.ReferenceCanvas:=FDelphiCanvas;
  end;

but I could'nt try it, because the recompile tool seems to override all changes?!


/Edit: Using Delphi XE4 - TeeChart Pro v2013.08.130521 32bit VCL

Re: Memory leek using GDI instead of GDI+

Posted: Wed Oct 30, 2013 2:30 pm
by David
This problem is already fixed (InternalCanvas.Free), and will be included in next update.

btw: If you apply the changes at "...\TeeChart Sources\VCL" folder, changes are lost because TeeRecompile tool recreates this folder.
The "original" source unit that can be modified are one level up, at "..\TeeChart Sources" folder.