Sanmarie
asked on
Using Close, Dispose and Nothing
Using .NET 2.0, VS 2005, VB.net
I have a connection object (global scope) and other objects that I want to remove from memory when finished. I call Close, then Dispose then set it to nothing. Is this a good way to clear up the object or is this too much. Also, I call the garbage collector after all of this.
Thanks
San
I have a connection object (global scope) and other objects that I want to remove from memory when finished. I call Close, then Dispose then set it to nothing. Is this a good way to clear up the object or is this too much. Also, I call the garbage collector after all of this.
Thanks
San
myOleDbConnection.Close()
myOleDbConnection.Dispose()
myOleDbConnection = Nothing
GC.Collect()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
GC.Collect() is not commonly used, there are several discussions about that in Intenet you can google.
ASKER
Ok. Fair enough. Thanks
San
San
ASKER
Then what's the purpose of anyone calling GC.Collect() if the garbage collector is going to run on its own time?
San