I'm using code below to make gf files of chart, the loop can be executed many hundreds of times. There appears to be a memory leak with this, should I be freeing something after the call to teecreatebitmap?
thans
Sean
tmpgif:=tgifimage.Create;
for c:=1 to no_of_var do
begin
get_chart1;
with tmpgif do
begin
compression:=gcLZW;
dithermode:=dmstucki;
colorreduction:=rmquantizewindows;
begin
assign(chart1.TeeCreateBitmap(chart1.Color,rect(0,0,chart1.Width,chart1.Height)));
savetofile(fname1);
end
end;
end;
tmpgif.Free;
Teecreatebitmap
-
- Newbie
- Posts: 19
- Joined: Thu Sep 27, 2007 12:00 am
- Location: UK
- Contact:
Re: Teecreatebitmap
Hi Sean Murphy,
I think that using an intermediate temporal Bitmap to store the TeeCreateBitmap result and freeing it at each iteration would solve the problem. Something like this:
I think that using an intermediate temporal Bitmap to store the TeeCreateBitmap result and freeing it at each iteration would solve the problem. Something like this:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var series1: TChartSeries;
tmpgif: TGIFImage;
tmpBitmap: TBitmap;
c, no_of_var: Integer;
fname1: string;
begin
no_of_var := 100;
for c:=1 to no_of_var do
begin
tmpgif:=tgifimage.Create;
with tmpgif do
begin
Compression:=gcLZW;
DitherMode:=dmStucki;
ColorReduction:=rmQuantizeWindows;
fname1 := 'C:\tmp\pics\tmpGif' + IntToStr(c) + '.gif';
tmpBitmap := chart1.TeeCreateBitmap(Chart1.Color,Rect(0,0,Chart1.Width,Chart1.Height));
Assign(tmpBitmap);
SaveToFile(fname1);
end;
FreeAndNil(tmpgif);
FreeAndNil(tmpBitmap);
end;
ShowMessage('Process Finished!');
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |