Board index » delphi » is this a BUG, or am i missing something

is this a BUG, or am i missing something

After lots of sweat and struggle, finding a memory loss, i think i've
narrowed it down to one thing.

the question is :
     Does Bitmap.SaveToFile releases memory that is used to save to the
file

Do the following as an exercise

procedure CheckMem;
var aBitmap : Tbitmap;
      i : LongIntr;
begin
Go:=True;
i:=0;
while Go do begin
  aBitmap:=TBitmap.Create;
  aBitmap.Loadfromfile('handshak.bmp');
  aBitmap.savetofile(inttostr(i)+'.bmp');
  aBitmap.Free;
  i:=i+1;
Application.ProcessMessages;
end;

put the above in the event of one button, and in the event of another
button, put Go:=False;

Run this
Using System Monitor (program/accessories/system monitor)
look at the locked memory and allocated memory graphs
They just rise and rise and rise.

Why is this? What can one do to free the memory allocated by
savetofile??

Thanks

Conrad Smith
qutes...@icon.co.za

 

Re:is this a BUG, or am i missing something


If one view the SaveToFile method if TGraphic, it uses the TFileStream
object.

So it seems the problems lies with the destroy event of the TFileStream
object
all that is called at the destroy event is FileClose(FHandle);

BTW,  i'm using Delphi 3.0

Thanks
Conrad Smith

Quote
Conrad Smith wrote:
> After lots of sweat and struggle, finding a memory loss, i think i've
> narrowed it down to one thing.

> the question is :
>      Does Bitmap.SaveToFile releases memory that is used to save to the
> file

> Do the following as an exercise

> procedure CheckMem;
> var aBitmap : Tbitmap;
>       i : LongIntr;
> begin
> Go:=True;
> i:=0;
> while Go do begin
>   aBitmap:=TBitmap.Create;
>   aBitmap.Loadfromfile('handshak.bmp');
>   aBitmap.savetofile(inttostr(i)+'.bmp');
>   aBitmap.Free;
>   i:=i+1;
> Application.ProcessMessages;
> end;

> put the above in the event of one button, and in the event of another
> button, put Go:=False;

> Run this
> Using System Monitor (program/accessories/system monitor)
> look at the locked memory and allocated memory graphs
> They just rise and rise and rise.

> Why is this? What can one do to free the memory allocated by
> savetofile??

> Thanks

> Conrad Smith
> qutes...@icon.co.za

Other Threads