Newbie question on object disposal

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hi,

In my windows application, I am creating multiple forms
that are hidden once the user is finished with them.

What is the best way to make sure the form are really
destroyed as soon as possible (and that their ressource
is released).

Any help here would be welcome.

James
 
John said:
In .NET you don't have to worry about setting objects to
Nothing, etc. like you did in VB6.

This is not quite true. You need to worry about setting
references to unused objects to Nothing, because otherwise
the GC can't collect it. Of course, local variables go
out of scope at the end of a method, but this was also
true in VB6. The main differences are that objects are
not disposed immediately, and that objects with cyclic
references will also be collected correctly if they
are not reachable from the root.

Objects which hold vital resources should also implement
the Dispose method so they can be released deterministically
without calling the garbage collector.
 
Back
Top