Search code examples
c#wcfstreaminglarge-data

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>

Solution

  • 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.