WCF System.InsufficientMemoryException
Getting this error when calling my WCF service. The service is streaming a 150mb file. It usually works the first time I call it, even the second, then I start getting the error.
error message : Failed to allocate a managed memory buffer of 268435456 bytes. The amount of available memory may be low.
I don't event know exactly where that number (268435456) comes from. Here is my config.
Code:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://localhost:53761/StreamService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStreamService"
contract="StreamService.IStreamService" name="BasicHttpBinding_IStreamService" />
<endpoint address="http://localhost:53761/ProgressService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProgressService"
contract="ProgressService.IProgressService" name="BasicHttpBinding_IProgressService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IStreamService" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" transferMode="StreamedResponse">
<security mode="TransportCredentialOnly" />
</binding>
<binding name="BasicHttpBinding_IProgressService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>
Searched on google but found mostly nothing :(
Thanks for any help.
Re: WCF System.InsufficientMemoryException
in case it could help here's the stack trace:
Code:
System.Runtime.Fx.AllocateByteArray(Int32 size)
System.Runtime.InternalBufferManager.PooledBufferManager.TakeBuffer(Int32 bufferSize)
System.Runtime.BufferedOutputStream.AllocNextChunk(Int32 minimumChunkSize)
System.Runtime.BufferedOutputStream.WriteCore(Byte[] buffer, Int32 offset, Int32 size)
System.Runtime.BufferedOutputStream.Write(Byte[] buffer, Int32 offset, Int32 size)
System.Xml.XmlStreamNodeWriter.FlushBuffer()
System.Xml.XmlUTF8NodeWriter.WriteBase64Text(Byte[] buffer, Int32 offset, Int32 count)
System.Xml.XmlUTF8NodeWriter.WriteBase64Text(Byte[] trailBytes, Int32 trailByteCount, Byte[] buffer, Int32 offset, Int32 count)
System.Xml.XmlBaseWriter.WriteBase64(Byte[] buffer, Int32 offset, Int32 count)
System.Xml.XmlDictionaryWriter.WriteValue(IStreamProvider value)
System.ServiceModel.Dispatcher.StreamFormatter.Serialize(XmlDictionaryWriter writer, Object[] parameters, Object returnValue)
System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)
System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)
System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
System.ServiceModel.Channels.Message.WriteMessage(XmlDictionaryWriter writer)
System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
System.ServiceModel.Channels.HttpRequestContext.OnReply(Message message, TimeSpan timeout)
System.ServiceModel.Activation.HostedHttpContext.OnReply(Message message, TimeSpan timeout)
System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc)