简体   繁体   中英

Client memory usage on WCF web service with large data

I have a WCF web service which needs to returns a file (Can be returned by a byte array or by streaming). I was first returning a byte[] in the interface, which caused the client to go up to a 400MB memory usage (at peak) for a 100MB file. Since I need to reduce the client memory usage, I've added another interface which streams the file back to the client. This time, I witness a 600MB increase in the client (again, in peak). How can I reduce the client memory usage?

My current implementation of the server is as follows (streaming):

[ServiceContract]
public interface IOmriService
{
    [OperationContract]
    Stream GetAudio(string input);
}

App.config:

  <bindings>
    <basicHttpBinding>
       <binding name="HttpStreaming" maxReceivedMessageSize="67108864" transferMode="Streamed"/>
    </basicHttpBinding>
  </bindings>

As far as I know there is no way of doing it in WCF. What I did was using a "simple" http file download. This consumes almost no memory by the client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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