Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi XE2 DataSnap REST - "Out of memory" when i try to download a big file

I created a simple DataSnap REST server in Delphi XE2 and i have a method which returns a TStream object to transfer a file. This works well but when i try to download a big file (~2,5GB) i got an

"out of memory"

error message on the server side.

I would like to download the file via internet browser (http://localhost:8080/datasnap/rest/TServerMethods1/GetFile).

Can rest service return big files?

I read this question and tryed that solution which works well when i use a small file.

Here is my simple code:

function TServerMethods1.GetFile: TStream;
var
  FileStream: TFileStream;
begin
  FileStream := TFileStream.Create('d:\file.exe', fmOpenRead);
  Result := FileStream;
end;

How can i download a big file from a REST server via internet browser?

like image 730
greenboy Avatar asked Dec 05 '25 14:12

greenboy


1 Answers

The result of your function is a TStream, try to increase the amount of memory for your application How can I enable my 32-bit Delphi application to use 4gb of memory on 64-bit windows (via Wow64.exe)?

Anyway, you are loading a very big amount of data. You should create a function which gives you the result in more small chunks.

like image 82
RBA Avatar answered Dec 09 '25 13:12

RBA



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!