locked
ApplyChanges - ApplyChangeFailed memory issue RRS feed

  • Question

  • Hi

    I had a bug in my INSERT Command

    BEGIN
        INSERT INTO  ...... ;
        SET @sync_row_count = @@ROWCOUNT;
    IF (@sync_row_count = 0 AND @sync_force_write = 1)
            UPDATE ......
            SET  .......
            WHERE [id] = @id;
            SET @sync_row_count = @@ROWCOUNT ;
    END;


    It should have been (notice the begin / end for the if)

    BEGIN
        INSERT INTO  ...... ;
        SET @sync_row_count = @@ROWCOUNT;
    IF (@sync_row_count = 0 AND @sync_force_write = 1)
        BEGIN
            UPDATE ......
            SET  .......
            WHERE [id] = @id;
            SET @sync_row_count = @@ROWCOUNT ;
        END;
    END;


    This meant that the ApplyChangeFailed event was being raised for each and every insert I attempted, because the sync_row_count was being reset to zero.

    This wasn't noticed for small change datasets but it did come to my attention for large datasets (in our case this could be over 140K rows to be inserted).

    The way it came to my attention was a crash within the call to ApplyChanges with an out of memory exception. After some investigation and memory profiling it shown that after raising 140k ApplyChangeFailed events, the sync process had acquired 1.6Gb of memory.

    It appears that the act of creating and raising the ApplyChangeFailed event is consuming and retaining a lot of memory.

    When I fix my SQL error the sync works for large datasets, I thought you might be interested in the observed behoviour of ApplyChanges/ApplyChangeFail.


    Regards

    Aidan

     


    • Moved by Hengzhe Li Friday, April 22, 2011 7:56 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, October 29, 2008 9:45 AM

All replies

  • Areel, thanks for sharing your experience. Surely this can help others who may encounter similar problems.

     

    Friday, October 31, 2008 5:59 AM