Sync throwing OutOfMemoryException RRS feed

  • Question

  • Hi,

    We have built a file sync solution using custom provider, to sync contents of two folders kept at two remote computers.
    However, this is throwing error "System.OutOfMemoryException" when the file size is about 1 GB.
    Can someone suggest how this issue can be fixed? Below is the stack trace:

    "Exception of type 'System.OutOfMemoryException' was thrown.

    Server stack trace:
       at System.IO.ByteBufferPool.GetBuffer()
       at System.Runtime.Remoting.Channels.ChunkedMemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
       at System.IO.BinaryWriter.Write(Byte[] buffer)
       at System.Runtime.Serialization.Formatters.Binary.__BinaryWriter.WriteSingleArray(NameInfo memberNameInfo, NameInfo arrayNameInfo, WriteObjectInfo objectInfo, NameInfo arrayElemTypeNameInfo, Int32 length, Int32 lowerBound, Array array)
       at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)
       at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
       at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
       at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SerializeMessage(IMessage msg, ITransportHeaders& headers, Stream& stream)
       at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at RemoteSync.Remoting.RemotingType.UploadFile(String folderPath, ItemMetadata item, Byte[] fileBytes, FileInformation fileInfo)
       at RemoteSync.SyncFramework.RemoteStore.SaveItemChange(SaveChangeAction saveChangeAction, ItemChange change, SaveChangeContext context) "

    • Moved by Max Wang_1983 Tuesday, April 19, 2011 10:46 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Monday, September 14, 2009 4:36 AM


  • Hi,

    When you say "custom provider" I assume you are not using Microsoft Sync Framework's out-of-the-box File Sync Provider (correct me otherwise).

    When your destination endpoint requires file to be copied over, are you reading the entire 1GB file into a memory buffer ? That could explain out of memory exception. Microsoft's FileSyncProvider works around this by copying chunks of file instead of entire file (and has some other optimizations as well).

    See if copying blocks of file works for you.

    Hope this helps,

    PS: Also, if you are not using MSF's FileSyncProvider, do let us know why not - we value your feedback to improve our products.

    Wednesday, December 23, 2009 11:43 PM