Dave Simione
Dave Simione

Reputation: 1441

Sync Framework 2.0 + WCF Service - OutofMemoryException

I have a process using Microsoft Sync Framework 2.0 across a WCF Service (IIS Hosted) to synchronize a SQL 2008 Standard database (server) and SQL CE 3.5 (client). All was working perfectly, until a single user started receiving OutOfMemory Exceptions. As it turns out, this user has a dataset that is significantly larger than any other user.

The dataset in question is 800,000 rows, with a total size when exported to CSV from SSMS of 174MB. Most users are in the 20-30MB range, which works fine.

I am using the DbServerSyncProvider, and SqlCeClientSyncProvider.

I have implemented batching as described in other articles and posted, to no avail. As I understand it, the batching mechanism in the DbServerSyncProvider is just how many revisions of the data to retrieve in one pull. Even with an anchor difference of 1, I still result in the same sized dataset.

I am using transferMode="Streamed" on my service, and I have applied the fix for Streamed when hosting in IIS.

I have tried upping the maxReceivedMessageSize, first from 20MB to 200MB, then to 2GB, and finally to 10GB, all with no success. This was done on both the server and client.

My WCF Trace logs show the Execute of GetChanges, but never logs anything under Process action.

I have read about the SqlSyncProvider, and how it allows batching by memory size. I can't find much information about using this through a WCF Service, though, and before I attempt to rewrite my client and server using this, I wanted to check if I was being an idiot on something and whether the SqlSyncProvider could solve my issue, along with being able to transfer across a WCF Service.

Thanks in advance...

Upvotes: 0

Views: 1404

Answers (1)

JuneT
JuneT

Reputation: 7860

The out of memory is most likely caused by the way Datasets are serialized.

If you want to re-write using the SqlSyncProvider, check out the section Code Specific to N-Tier on this link: http://msdn.microsoft.com/en-us/library/dd918908.aspx#Y3096. That should give you an idea on writing the WCF service component for the SqlSyncProvider.

You may also check out the sample SQL Server and SQL Compact N-Tier with WCF

If you want to retain your existing providers, you can play around using DatasetSurrogates. Check out a sample here: Sync Framework WCF-based Synchronization for Offline scenario – Using custom dataset serialization

Upvotes: 2

Related Questions