Consider the following code downloading a file from the Internet using Indy components:
procedure TForm26.Button1Click(Sender: TObject); var vFileStream : TStream; begin DeleteFile('C:\test.exe'); vFileStream := TFileStream.Create('C:\test.exe', fmCreate); IdHTTP1.Get('SomeUrl', vFileStream); vFileStream.Free; end;
I am getting a memory exception. It happens that in addition to the fact that I use TFileStream
, the bytes that are written to it do not go directly to the disk, instead they remain in memory until get
is completed.
The file I'm trying to download is really very large.
Does anyone know how to load a large file without exception from memory?
Delphi 2010 and the latest Indy 10 from Indy SVN.
EDIT
This is not a FileStream
problem. This is an Indy
problem. Indy somehow caches the file in memory before writing to the stream.
source share