|Subject:||Re: slow operation using RetrieveRaw with a TString|
|Posted by:||Remy Lebeau \(Indy Team\) (firstname.lastname@example.org)|
|Date:||Wed, 18 Nov 2009|
"Aur=E9lien" <email@example.com> wrote in message =
> i encounter some long timings using RetrieveRaw with a TStringStream=20
> object, trying to handle mails with large attachements (greater than 1 =
> nevertheless, the network activity seems to be ok, the message is=20
> quickly received : it seems that other (slow) operations occur in the=20
> function after the file has been received.
Do you have the same problem if you use a TMemoryStream instead? =
RetreiveRaw() has to perform a lot of small writes to the target stream. =
TMemoryStream is more optimized than TStringStream when it comes to =
allocating, reallocating, and accessing the stream's internal memory.
> AssignFile(Fichier, 'd:\t\mail.txt');
> FileMode :=3D fmOpenWrite;
> Write(Fichier, Flux.DataString);
That is old-style Pascal file I/O. If you switch to TMemoryStream, you =
gain access to its SaveToFile() method. If you continue using =
TStringStream, you should at least use VCL-style file I/O instead. Look =
at the FileCreate() and FileWrite() functions. Or, use a separate =
TFileStream and call its CopyFrom() method.
Remy Lebeau (TeamB)
slow operation using RetrieveRaw with a TString posted by Aurélien on Wed, 18 Nov 2009