InsertAllOnSubmit Memory Leak Exception
InsertAllOnSubmit Memory Leak Exception
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();
}
Re: InsertAllOnSubmit Memory Leak Exception
The same occurs if i use a new context instance. After minutes... throws OutMemoryExcpetion because holds the memory i check task manger too
Is there anything wrong with my interact with LINQ so that causes the memory hold up and not being released.
private void TryBackup(DateTime day)
{
var innerMBackupGpsDataContext = new MultiGpsBackupDataContext { EntityCachingMode = EntityCachingMode.WeakReference };
var pendingRows = GetOldestDayRowsToBackup(day);
var backupRows = pendingRows.Select(x => GetGpsHistoricBackup(x));
try
{
innerMBackupGpsDataContext.Gpshistoricbackups.InsertAllOnSubmit(backupRows);
innerMBackupGpsDataContext.SubmitChanges();
innerMBackupGpsDataContext.Dispose();
GC.Collect();
}
catch (Exception ex)
{
}
}
Is there anything wrong with my interact with LINQ so that causes the memory hold up and not being released.
private void TryBackup(DateTime day)
{
var innerMBackupGpsDataContext = new MultiGpsBackupDataContext { EntityCachingMode = EntityCachingMode.WeakReference };
var pendingRows = GetOldestDayRowsToBackup(day);
var backupRows = pendingRows.Select(x => GetGpsHistoricBackup(x));
try
{
innerMBackupGpsDataContext.Gpshistoricbackups.InsertAllOnSubmit(backupRows);
innerMBackupGpsDataContext.SubmitChanges();
innerMBackupGpsDataContext.Dispose();
GC.Collect();
}
catch (Exception ex)
{
}
}
Re: InsertAllOnSubmit Memory Leak Exception
Testing i noticed that:
The issue only happens using Windows Forms
In console app no memory leak
The issue only happens using Windows Forms
In console app no memory leak
Re: InsertAllOnSubmit Memory Leak Exception
Could you please provide us with a small test project, so that we are able to investigate this issue in more details.
Re: InsertAllOnSubmit Memory Leak Exception
I found the cause, it is an incompatibility with other components, only happens when I use a form DevComponents.DotNetBar.Metro.MetroForm type. I can send the sample project, but you need to have these components installed. I am very interested in that could work together.
Re: InsertAllOnSubmit Memory Leak Exception
Yes, most likely this error is related to DevComponents.DotNetBar.Metro.MetroForm component, not LinqConnect.
However, please send us the sample project and specify the stack trace of the exception you are getting.
We will investigate it and inform you about the results as soon as any are available.
However, please send us the sample project and specify the stack trace of the exception you are getting.
We will investigate it and inform you about the results as soon as any are available.
Re: InsertAllOnSubmit Memory Leak Exception
I sent it
Thanks
Thanks
Re: InsertAllOnSubmit Memory Leak Exception
Thank you for the sample project. We couldn't reproduce the OutOfMemoryException with your sample project, LinqConnect 4.2.247 and DotNetBar for Windows Forms Trial 11.2 (DevComponents.DotNetBar.Metro.MetroForm).
Please specify the stack trace of the exception.
Please specify the stack trace of the exception.