set data connection to nothing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was just told that it is good practice to set a data connection to nothing
after it is closed becaue this will clear the object. Other wise the dataset
is closed but the object will remain until it times out. Is this really true
or is a holdover from asp?
Example:
conSlb.Close()
conSlb = Nothing

thanks kes
 
Hi Kurt,

The instance will remain in memory at least until one valid reference is
active.
When there are no valid references then the instance is scheduled for
garbage collection which occurs when garbage collector runs.
So, yes, if you set reference to null (or nothing in VB.net) the memory kept
by instance will be probably released sooner.
BTW, rather then Close use Dispose.
 
Back
Top