Hewitt, Simon C. (Contractor)
2007-06-12 06:52:58 UTC
Here is a fix I found for a memory leak when replacing the DataTable a
DataView is wrapped around:
// Do this
FieldInfo fi = typeof(DataView).GetField("delayBeginEditList",
BindingFlags.Instance | BindingFlags.NonPublic);
fi.SetValue(view, null);
// before doing this
View.Table = newTable;
If you don't clear the delayBeginEditList before assigning the new
DataTable, it retains a reference to a DataRow in the *old* DataTable,
which keeps the old DataTable in memory.
Cheers
Simon
===================================
This list is hosted by DevelopMentor� http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
DataView is wrapped around:
// Do this
FieldInfo fi = typeof(DataView).GetField("delayBeginEditList",
BindingFlags.Instance | BindingFlags.NonPublic);
fi.SetValue(view, null);
// before doing this
View.Table = newTable;
If you don't clear the delayBeginEditList before assigning the new
DataTable, it retains a reference to a DataRow in the *old* DataTable,
which keeps the old DataTable in memory.
Cheers
Simon
===================================
This list is hosted by DevelopMentor� http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com