ComponentOne DataObjects for .NET
Avoiding a Memory Leak
DataObjects for .NET Task-Based Help > Avoiding a Memory Leak

It is possible you may experience a memory leak when using DataObjects for .NET and True DBGrid for WinForms. You may lose information, or the memory usage of your program may increase.

In order to avoid this problem, try adding the following code to your project:

To write code in Visual Basic

Visual Basic
Copy Code
Dim f As MyForm = New MyForm
Try
 f.ShowDialog
Finally
 CType(f, IDisposable).Dispose()
End Try
f = Nothing
 
OR
 
Using f As New MyForm
 f.ShowDialog
End Using

To write code in C#

C#
Copy Code
using ( MyForm f = new MyForm() );
{
    f.ShowDialog();
}
 
OR
 
MyForm f = new MyForm();
using ( f )
{
    f.ShowDialog();
}
f = null;
Tip: To avoid memory leaks try to avoid unnecessary memory allocation – for example avoid recreating an editing child form every time a user edits a row.