Answered by:
OutOfMemoryException in MemoryStream

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)- Edited by Aristeidis Bampakos Monday, September 26, 2011 10:13 AM additional information
Monday, September 26, 2011 10:08 AM
Answers
-
the error you're getting is its not able to allocate enough memory... you're most likely running into the same problem with serializing/deserializing datasets.
- Marked as answer by Aristeidis Bampakos Wednesday, September 28, 2011 6:37 AM
Monday, September 26, 2011 11:15 AM
All replies
-
do you have enough physical memory on your device?Monday, September 26, 2011 10:42 AM
-
This is the memory usage when my application is running and before execute the sync process.
- Edited by Aristeidis Bampakos Monday, September 26, 2011 10:50 AM
Monday, September 26, 2011 10:49 AM -
the error you're getting is its not able to allocate enough memory... you're most likely running into the same problem with serializing/deserializing datasets.
- Marked as answer by Aristeidis Bampakos Wednesday, September 28, 2011 6:37 AM
Monday, September 26, 2011 11:15 AM -
I used the sample above and I get a protocol error during synchronization (Cannot process the message because the content type 'application/soap+xml;charset=utf-8;...... was not the expected type 'application/x-gzip'.). I managed finally to download a wav file using the sample above and Basic Http Binding on the service. Is it possible to use the sample with custom binding and GZipEncoder?
- Edited by Aristeidis Bampakos Tuesday, September 27, 2011 11:49 AM Additional info
Tuesday, September 27, 2011 9:25 AM -
try removing your gzip compression.Wednesday, September 28, 2011 2:18 AM