locked
OutofMemoryException while loading client side data RRS feed

  • Question

  • I have a winCE device where i am syncing data (from sqlce database, a .sdf file) to SQL server.

    While reading the data from the client side database (which is getting uploaded to the SQL server), I am getting outofmemoryexception.

       at System.Collections.Generic.SortedList`2.set_Capacity(Int32 value)
       at System.Collections.Generic.SortedList`2.EnsureCapacity(Int32 min)
       at System.Collections.Generic.SortedList`2.Insert(Int32 index, String key, String value)
       at System.Collections.Generic.SortedList`2.Add(String key, String value)
       at Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider.GetUniqueKeys(DataTable table)
       at Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider.EnumerateInserts(SyncGroupMetadata groupMetadata,

    SortedList`2[]& listOfInserts, Int64 enumTxCsn)
       at Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider.GetChanges(SyncGroupMetadata groupMetadata,

    SyncSession syncSession)
       at Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider.GetChanges(IEnumerable`1 tableNames)
       at Microsoft.Synchronization.Data.SqlServerCe.SqlCeClientSyncProvider.GetChanges(String tableName)

     

    We have implemented batching for sending the data from client side to server and it works fine. But how to get all the changes from the local client database without getting into outofmemoryexception?

    Please help.

    Wednesday, January 4, 2012 10:27 AM

Answers

  • Hi,

    if this is the single table with large data changes and you don't ahve extra RAM on the device, this is a situation that you might not be able to sync the DB to the server due to the OOM exceptions. note that due to some behavior in DataTable/DataSet, the memory consumption would be much bigger than the data itself.

    you might want to get the query to run at the DB level to see how large the data is and save the changed data. you could reinitialize the local sql CE db and the make the data changes in a smaller chunk and sync to the server to avoid the OOM exception.

    here is the link you can refer to get the query for data changes: http://blogs.msdn.com/b/sync/archive/2011/03/02/synchronization-services-for-ado-net-for-devices-improving-performance-by-skipping-tables-that-don-t-need-synchronization.aspx

     

    thanks

    Yunwen

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Yunwen Bai Monday, January 9, 2012 9:40 PM
    Thursday, January 5, 2012 10:31 PM

All replies

  • Hi there,

    Try lowering your MemoryDataCacheSize on the SqlSyncProvider.  This controls the max size of memory used per batch.

    -Jesse

    Wednesday, January 4, 2012 7:21 PM
  • Thanks Jesse,

     

    I have code like below.

    SqlCeClientSyncProvider clientSyncProvider = new SqlCeClientSyncProvider(sdf connection sting, false);

    _changesContext = clientSyncProvider.GetChanges(dbSyncTable.TableName);

     

    I get outofmemory in the italics line.

    I understand that the property you mentioned is not available in SqlCEClientSyncProvider.

    http://social.microsoft.com/Forums/en/syncdevdiscussions/thread/71c60538-cd0f-4514-b1f4-5ec2811ba50b

    Any other ideas?

    Thursday, January 5, 2012 5:41 AM
  • Hi,

    if this is the single table with large data changes and you don't ahve extra RAM on the device, this is a situation that you might not be able to sync the DB to the server due to the OOM exceptions. note that due to some behavior in DataTable/DataSet, the memory consumption would be much bigger than the data itself.

    you might want to get the query to run at the DB level to see how large the data is and save the changed data. you could reinitialize the local sql CE db and the make the data changes in a smaller chunk and sync to the server to avoid the OOM exception.

    here is the link you can refer to get the query for data changes: http://blogs.msdn.com/b/sync/archive/2011/03/02/synchronization-services-for-ado-net-for-devices-improving-performance-by-skipping-tables-that-don-t-need-synchronization.aspx

     

    thanks

    Yunwen

     


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Yunwen Bai Monday, January 9, 2012 9:40 PM
    Thursday, January 5, 2012 10:31 PM