InsertAllOnSubmit Memory Leak Exception
Posted: Fri 10 May 2013 17:31
Im trying to backup large amount of data, but OutOfMemoryException throws, in task manager reach from 20mb, then 30mb, 40mb.. to ~1.5gb used.
GetChangeSet() is reset correctly at each iteration
I set EntityCachingMode.WeakReference, but no success
And i notice that the memory usage keeps increasing while looping. I even force garbage collection also cannot reclaim any of the memory.
Im using dotConnect for MySQL 7.6.226 (LinqConnect), VS2012.2, Win8x64
Is there anything wrong with my interact with LINQ so that causes the memory hold up and not being released.
Sorry my english is not so good
Thanks in advance!
var oldestDayToBackup = GetOldestDayToBackup();
while (oldestDayToBackup != null)
{
var day = (DateTime)oldestDayToBackup;
var dayRowCount = GetOldestDayToBackupRowCount(day);
while (dayRowCount > 0)
{
var pendingRows = GetOldestDayRowsToBackup(day);
try
{
MBackupGpsDataContext.Gpshistoricbackups.InsertAllOnSubmit(pendingRows);
MBackupGpsDataContext.SubmitChanges();
GC.Collect()
}
catch (Exception ex)
{
}
dayRowCount = GetOldestDayToBackupRowCount(day);
}
oldestDayToBackup = GetOldestDayToBackup();
}
GetChangeSet() is reset correctly at each iteration
I set EntityCachingMode.WeakReference, but no success
And i notice that the memory usage keeps increasing while looping. I even force garbage collection also cannot reclaim any of the memory.
Im using dotConnect for MySQL 7.6.226 (LinqConnect), VS2012.2, Win8x64
Is there anything wrong with my interact with LINQ so that causes the memory hold up and not being released.
Sorry my english is not so good
Thanks in advance!
var oldestDayToBackup = GetOldestDayToBackup();
while (oldestDayToBackup != null)
{
var day = (DateTime)oldestDayToBackup;
var dayRowCount = GetOldestDayToBackupRowCount(day);
while (dayRowCount > 0)
{
var pendingRows = GetOldestDayRowsToBackup(day);
try
{
MBackupGpsDataContext.Gpshistoricbackups.InsertAllOnSubmit(pendingRows);
MBackupGpsDataContext.SubmitChanges();
GC.Collect()
}
catch (Exception ex)
{
}
dayRowCount = GetOldestDayToBackupRowCount(day);
}
oldestDayToBackup = GetOldestDayToBackup();
}