@@ -152,10 +152,11 @@ public virtual Task<BatchInfo> CreateSnapshotAsync(SyncParameters syncParameters
152
152
if ( bptis != null )
153
153
{
154
154
// Statistics
155
- var tableChangesSelected = new TableChangesSelected ( table . TableName , table . SchemaName ) ;
156
-
157
- // we are applying a snapshot where it can't have any deletes, obviously
158
- tableChangesSelected . Upserts = bptis . Sum ( bpti => bpti . RowsCount ) ;
155
+ var tableChangesSelected = new TableChangesSelected ( table . TableName , table . SchemaName )
156
+ {
157
+ // we are applying a snapshot where it can't have any deletes, obviously
158
+ Upserts = bptis . Sum ( bpti => bpti . RowsCount )
159
+ } ;
159
160
160
161
if ( tableChangesSelected . Upserts > 0 )
161
162
changesSelected . TableChangesSelected . Add ( tableChangesSelected ) ;
@@ -260,7 +261,7 @@ internal virtual async Task<BatchInfo> InternalCreateSnapshotAsync(SyncContext c
260
261
var row = this . CreateSyncRowFromReader ( dataReader , changesSetTable ) ;
261
262
262
263
// Add the row to the changes set
263
- changesSetTable . Rows . Add ( row ) ;
264
+ changesSetTable . Rows . Add ( row ) ;
264
265
265
266
// Set the correct state to be applied
266
267
if ( row . RowState == DataRowState . Deleted )
@@ -292,7 +293,8 @@ internal virtual async Task<BatchInfo> InternalCreateSnapshotAsync(SyncContext c
292
293
batchIndex ++ ;
293
294
294
295
// we know the datas are serialized here, so we can flush the set
295
- changesSet . Clear ( ) ;
296
+ changesSet . Dispose ( ) ;
297
+ changesSetTable . Dispose ( ) ;
296
298
297
299
// Recreate an empty ContainerSet and a ContainerTable
298
300
changesSet = new SyncSet ( ) ;
@@ -301,9 +303,12 @@ internal virtual async Task<BatchInfo> InternalCreateSnapshotAsync(SyncContext c
301
303
302
304
// Init the row memory size
303
305
rowsMemorySize = 0L ;
306
+
307
+ GC . Collect ( ) ;
304
308
}
305
309
306
310
dataReader . Close ( ) ;
311
+ GC . Collect ( ) ;
307
312
308
313
// We don't report progress if no table changes is empty, to limit verbosity
309
314
if ( tableChangesSelected . Deletes > 0 || tableChangesSelected . Upserts > 0 )
0 commit comments