Yes, it is memory leak.
In C# you have something like two kinds of memory. Managed memory and unmanaged memory. Managed memory is managed by GC :) Unmanaged is not. You have to free unmanaged memory by yourself. So for example (managed):
{
List<int> l = new List<int();
}
This one won't create memory leak. After l goes out of scope it is marked to be freed. It is marked not freed. It may be freed later (list destructor will be called then).
So how about unmanaged memory?
{
MyForm f = new MyForm();
}
This is memory leak. When f goes out of scope, its unmanaged memory is not managed by GC at all. So you have to free it by yourself:
{
MyForm f = new MyForm();
f.ShowDialog();
f.Dispose();
}
Dispose method frees all unamanaged memory. So now you may have two questions:
1. How do I know if a class is managed or unmanaged?
It's pretty simple. You can assume that all classes that implement IDisposable interface (contain Dispose() method) are unmanaged - they are unmanaged by themselves or they consist of unmanaged classes. Especially every resources like fonts, streams, forms, database connections and so on.
- How should I free modeless form?
You could store a reference to that form and dispose it when it's no longer necessary. You could call Dispose in FormClosed event ( https://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosed.aspx )