nothing or dispose

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

Guest

hi

iam closing the connection and later iam using dispose method

should i need to use nothin

is it neccessary to use nothing for an object??????

pls give me suggestion
 
Hello Rahim,
Generally, setting an object to "nothing" is never necessary. When You set an object to nothing, this means that the GC can collect that object(if there are no other references to that object). You can just leave it, and as the variable leaves it's scope, the result will be the same. Anyhow, if You are trying to fine-tune Your app in terms of memory usage, and You are using a global connection object which, is SOME CASE, isn't needed any more in some early stage of execution, You can set it to nothing. Then You MIGHT get some profit if a GC occurs during the program execution. For a small program, this is very unlikely to happen.:)
 
In general it's not necessary to set your objects to nothing, GC takes care
of it. With regards to closing and disposing your connection, well the
Dispose method actually takes care of closing the connection as well, so you
can leave out the call to the Close method. However, as you indicate, the
Close and Dispose methods aren't called at the same time, so you might want
call both of them, depending on your setup.
 
Back
Top