Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-02

mem-leak in TStrings.SaveToFile?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joost van der Sluis

Hi all,

See here the code from TStrings.SaveToFile:

Procedure TStrings.SaveToFile(const FileName: string);
Var TheStream : TFileStream;
begin
  TheStream:=TFileStream.Create(FileName,fmCreate);
  SaveToStream(TheStream);
  TheStream.Free;
end

Doesn't this leak memory when the file is locked, for example? And is is allowed to add the 'try .. finally' here? (It's in objpas/classes so that should be possible?)

Joost.

Reply by email

Michael Van Canneyt
to Joost van der Sluis
Joost van der Sluis wrote 17 lines
Hi all, See here the code from TStrings.SaveToFile: Procedure TStrings.SaveToFile(const FileName: string); Var TheStream : TFileStream; begin TheStream:=TFileStream.Create(FileName,fmCreate); SaveToStream(TheStream); TheStream.Free; end Doesn't this leak memory when the file is locked, for example? And is is allowed to add the 'try .. finally' here? (It's in objpas/classes so that should be possible?)

It *must* be there :)

Michael.

Reply by email