简体   繁体   English

WCF大文件上传中的内存异常不足

[英]Insufficient Memory Exception in WCF Large File Uploading

I am trying to upload large files(>10GB) using WCF. 我正在尝试使用WCF上传大文件(> 10GB)。 The Service Web.config is as below 服务Web.config如下

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding" maxBufferPoolSize="2147483647000000" maxReceivedMessageSize="2147483647000000" transferMode="Streamed">
      <readerQuotas maxDepth="200000000" maxStringContentLength="2147483647"
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

<client>
  <endpoint address="http://localhost:42890/Service1.svc"  behaviorConfiguration="endpointBehavior"
    binding="basicHttpBinding" 
    contract="UploadFileService.IService1" name="BasicHttpBinding"  />
</client>

And the client side web.config as below 和客户端的web.config如下

   <bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding" closeTimeout="10:00:00" openTimeout="10:00:00"
      receiveTimeout="10:00:00" sendTimeout="10:00:00" maxBufferPoolSize="2147483647000000"
      maxReceivedMessageSize="2147483647000000" />
  </basicHttpBinding>
</bindings>

I got insufficient memory exception when I run the code, How can I solve it? 运行代码时,内存不足异常,如何解决?

In your solution, target x64 instead of Any CPU. 在您的解决方案中,目标x64而不是任何CPU。 This will allow more memory allocation. 这将允许更多的内存分配。

However, depending on your solution, you might be able to Stream the file to disk, not requiring to use so much memory. 但是,根据您的解决方案,您也许可以将文件Stream传输到磁盘,而不需要使用太多内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM