我正在尝试同步大小为>的sql server数据库4GB。出现内存异常。尝试使用MemoryDataCacheSize& ApplicationTransactionSize。没有成功。代码在这里给出。
public static long BatchSize = 500000;
public static uint MemorySize = 4000000000;
public void Sync(ServerSyncHelper server)
{
try
{
SqlConnection clientConn = DBConnection;
SqlConnection serverConn = server.DBConnection;
SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
var localProvider = new SqlSyncProvider(ScopeName, clientConn);
localProvider.MemoryDataCacheSize = MemorySize;
localProvider.ApplicationTransactionSize = BatchSize;
syncOrchestrator.LocalProvider = localProvider;
var remoteProvider = new SqlSyncProvider(server.ScopeName, serverConn);
remoteProvider.ApplicationTransactionSize = BatchSize;
remoteProvider.MemoryDataCacheSize = MemorySize;
remoteProvider.ChangesApplied += new EventHandler<DbChangesAppliedEventArgs>(RemoteProvider_ChangesApplied);
syncOrchestrator.RemoteProvider = remoteProvider;
syncOrchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(ApplyChangeFailed);
SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
LogWriter.Write("Start Time: " + syncStats.SyncStartTime);
LogWriter.Write("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
LogWriter.Write("Complete Time: " + syncStats.SyncEndTime);
}
catch (Exception ex)
{
LogWriter.Write(ex);
}
}
答案 0 :(得分:2)
您的进程正在尝试分配太多内存(这由MemoryDataCacheSize控制)。 Look here for more information关于你想要做什么。