"Out of memory while expanding memory stream" 尝试使用 TIdHTTP 下载文件时出错

"Out of memory while expanding memory stream" error when attempting to download a file using TIdHTTP

我正在尝试使用 Delphi 10.4 中的标准 TIdHTTPTIdSSLIOHandler 组件从 Web 服务器下载文件:

memorystream := TMemoryStream.Create;
http.request.useragent:='Mozilla/5.0 (Windows NT 5.1; rv:2.0b8) Gecko/20100101 Firefox/4.0b8';
http.HandleRedirects := True;
try
  http.get('https://dl.nmkd.de/ai/clip/coco/coco.ckpt',memorystream);
except
  on E:Exception do memo.lines.add(E.Message);
  memo.lines.add(http.responsetext);
end;
application.ProcessMessages;
memorystream.SaveToFile('coco.ckpt');
memorystream.free;

我在备忘录中得到的回复是:

Out of memory while expanding memory stream
HTTP/1.1 200 OK

文件大小约为 9 GB。

如何让 MemoryStream 能够处理该大小?我在 PC 中安装的物理内存绰绰有余。

不用临时加载资源到内存,直接使用TFileStream加载到本地文件:

Stream := TFileStream.Create('coco.cpkt');
try
  try
    http.get('https://dl.nmkd.de/ai/clip/coco/coco.ckpt', Stream);
  except
    on E:Exception do memo.lines.add(E.Message);
  end;
finally
  Stream.Free;
end;