none
Sync Framework - OutOfMemoryException with table contains image field RRS feed

  • Question

  • Hi,

    I'm having an issue to sync table that contains image field which has more than 30 records, and it threw OutOfMemoryException. I know it is caused by the fact that Sync Framework v1.0 will download the whole dataset back to handheld's database before execute the insert or update command, and there is an article to get around it: How to: Specify the Order and Batch Size of changes (http://msdn.microsoft.com/en-us/library/bb902828(v=SQL.100).aspx). But I haven't try this yet because it is complicated to integrate to my current SyncProvider which is auto-generated by Sync Framework v1.0, to be honestly, I dont know to properly combine those 2 codes and dont want to break the current SyncProvider as it is working fine as long as I dont sync images (it works even with 10000 records)

    I try to set BatchSize = 10 in the provider's designer.cs, but no luck it still throw OutOfMemoryException. It seems I have to follow the guide above, but I have several unclear points and would like someone to help me out:

    Can I manually create InsertTimestamp and UpdateTimestamp fields on the server?

    Do I also need to create them on local database?

    Is there a better way to combine current sync code with the above code without to code everything from crash?

    Is there an alternative way to set BatchSize?

    Can I set BatchSize on client system?

    Please help me because I need to deploy this at mid of September.

    Thanks,

     

    Sam.

     

    Thursday, August 12, 2010 9:33 PM

Answers

  • you're stuck with v1 then :( the more robust device support will come in v3. you have no choice but to follow the article and implement batching.
    • Marked as answer by EverForest Wednesday, September 15, 2010 3:06 PM
    Thursday, August 19, 2010 3:47 PM
    Moderator
  • it's not yet a beta. just a preview  and is by invite only. check out the announcements here on how to get invited: http://social.microsoft.com/Forums/en-US/synclab/threads
    • Marked as answer by EverForest Wednesday, September 15, 2010 3:06 PM
    Thursday, September 9, 2010 11:47 PM
    Moderator
  • its a very early preview and afaik, its very unlikely it will come out in the next 2-3 mos. you might want to post the question in the preview forum as only the Sync Fx team can answer that :)

    • Marked as answer by EverForest Wednesday, September 15, 2010 3:07 PM
    Friday, September 10, 2010 11:54 PM
    Moderator

All replies

  • have you considered moving to V2 and use the collaboration providers instead? Batching support in V1 is a lot of work whereas in v2, it's just a property setting. if you use V1, you'll have to code the batching, in v2 you'll have to code everything because there is no designer support.
    Wednesday, August 18, 2010 1:49 AM
    Moderator
  • Hi JuneT,

    Thanks for your reply. I thought about moving to V2 as well, but does it support Windows Mobile 6.0? I forgot to mention my application is for WM6.

    Thanks.

    Thursday, August 19, 2010 3:30 PM
  • you're stuck with v1 then :( the more robust device support will come in v3. you have no choice but to follow the article and implement batching.
    • Marked as answer by EverForest Wednesday, September 15, 2010 3:06 PM
    Thursday, August 19, 2010 3:47 PM
    Moderator
  • I had a similar problem a while back. Another reason for the OutOfMemory exception is that TableAdapter parameters for image fields default to a ridiculously high number of bytes (from memory, the default length is about 3 GB!!) This is far more than you will ever need and way too big for any handheld device to cope with.

    If you are just sync'ing pictures taken from the device's camera (like I am), just adjust the TableAdapter paramter length for your image field (in your DataSet's XSD schema) to something more appropriate - mine are set to 1048576 (1 MB).

    TableAdapter parameter:

    <Parameter AllowDbNull="false" AutogeneratedName="p2" ColumnName="MyImage" DataSourceName="MyImages" DataTypeServer="image" DbType="Binary" Direction="Input" ParameterName="@p2" Precision="0" ProviderType="Image" Scale="0" Size="1048576" SourceColumn="MyImage" SourceColumnNullMapping="false" SourceVersion="Current" /><br/>
               
    

     

    Monday, August 23, 2010 7:35 AM
  • Hi SunHunter,

    Thanks for your reply. I looked at the max length for image field and it is 1GB, but I think it is a varible length which means it will automatically truncate the length to fix the actual image size. However, how do I modify the XSD file? where is the XSD file location?

     

    Thanks for your help

     

    Sam.

    Monday, August 23, 2010 6:49 PM
  • I had a similar problem a while back. Another reason for the OutOfMemory exception is that TableAdapter parameters for image fields default to a ridiculously high number of bytes (from memory, the default length is about 3 GB!!) This is far more than you will ever need and way too big for any handheld device to cope with.

    If you are just sync'ing pictures taken from the device's camera (like I am), just adjust the TableAdapter paramter length for your image field (in your DataSet's XSD schema) to something more appropriate - mine are set to 1048576 (1 MB).

    TableAdapter parameter:

    <Parameter AllowDbNull="false" AutogeneratedName="p2" ColumnName="MyImage" DataSourceName="MyImages" DataTypeServer="image" DbType="Binary" Direction="Input" ParameterName="@p2" Precision="0" ProviderType="Image" Scale="0" Size="1048576" SourceColumn="MyImage" SourceColumnNullMapping="false" SourceVersion="Current" /><br/>
    
          
    
    

     

    Hi SunHunter,

    I never use TableAdapter or xsd file to query the database file, I dont even have the table that contain the image field inside my xsd file, so this solution wont solve my issue, perhaps with another scenario.

    Sam.

    Wednesday, September 8, 2010 7:45 PM
  • Hi JuneT,

    I saw several forumn about MSF 3.0 release preview, and it seems like a beta review, do you know where can I download the beta version?

    • Marked as answer by EverForest Wednesday, September 15, 2010 3:06 PM
    • Unmarked as answer by EverForest Wednesday, September 15, 2010 3:07 PM
    Thursday, September 9, 2010 8:33 PM
  • it's not yet a beta. just a preview  and is by invite only. check out the announcements here on how to get invited: http://social.microsoft.com/Forums/en-US/synclab/threads
    • Marked as answer by EverForest Wednesday, September 15, 2010 3:06 PM
    Thursday, September 9, 2010 11:47 PM
    Moderator
  • Thanks JuneT, do you know the release date for V3.0 or at least the estimated time (1 or 2 months)?

    Friday, September 10, 2010 8:10 PM
  • its a very early preview and afaik, its very unlikely it will come out in the next 2-3 mos. you might want to post the question in the preview forum as only the Sync Fx team can answer that :)

    • Marked as answer by EverForest Wednesday, September 15, 2010 3:07 PM
    Friday, September 10, 2010 11:54 PM
    Moderator