none
OutOfMemoryException in MemoryStream RRS feed

  • Question

  • Hi,

    I have a smart device application that saves wav files in a table of SQL Compact Edition database and syncs them back in a SQL Server 2008 R2 database. The type of the field is IMAGE. When the wav file is 2 minutes, data are not be synced and OutOfMemoryException occurs.As I decrease the size of the wav gradually, until 1 minute, the wav file is synced to the database but OutOfMemoryException occurs right afterwards. Sometimes I also get the exception message: The buffer manager failed to allocate a buffer of .... bytes but data are not be synced in the database. The maxReceivedMessageSize and maxBufferSize of my WCF Service are set to 50000000 and I use GZipEncoder for compression. If I drop the sdf and download all data from the server, the sync process completes succesfully.

    Below are both stack traces:

     

    OutOfMemoryException

    System.IO.MemoryStream.ToArray()
    Microsoft.Samples.Indigo.GzipEncoder.CompressionMessageEncoder.DecompressBuffer(ArraySegment`1 buffer, BufferManager bufferManager)
    Microsoft.Samples.Indigo.GzipEncoder.CompressionMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
    System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
    System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
    System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
    System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
    System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Channels.RequestChannel.Request(Message message)
    Microsoft.Tools.ServiceModel.CFClientBase`1.getReply(Message msg)
    Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, ApplyChangesRequest request)

     

    The buffer manager failed to allocate a buffer of .... bytes

    System.ServiceModel.Channels.BufferManager.AllocBuffer(Int32 bufferSize)
    System.ServiceModel.Channels.BufferManager.GCBufferManager.TakeBuffer(Int32 bufferSize)
    Microsoft.Samples.Indigo.GzipEncoder.CompressionMessageEncoder.CompressBuffer(ArraySegment`1 buffer, BufferManager bufferManager, Int32 messageOffset)
    Microsoft.Samples.Indigo.GzipEncoder.CompressionMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
    System.ServiceModel.Channels.MessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager)
    System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
    System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
    System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
    System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Channels.RequestChannel.Request(Message message)
    Microsoft.Tools.ServiceModel.CFClientBase`1.getReply(Message msg)
    Microsoft.Tools.ServiceModel.CFClientBase`1.Invoke[TREQUEST,TRESPONSE](CFInvokeInfo info, ApplyChangesRequest request)

     

     


    Monday, September 26, 2011 10:08 AM

Answers

All replies