Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is Nothing better than nothing? 1

Status
Not open for further replies.

Isadore

Technical User
Feb 3, 2002
2,167
US
Which is preferred:

...
myreader.Close
dbconnSites.Close()

..or...

myreader.Close
myreader = Nothing
dbconnSites.Close()
dbconnSites = Nothing

...just curious.
 
If there is a Close method, it usually means that the object is holding unmanaged resources which should be released as soon as possible. The Close method is provided so that you can free them deterministically rather than wait on the non-deterministic behaviour of the Garbage Collection routine. It is also a good idea to set your object references to Nothing if you are through with the object and the object reference will not go out of scope soon. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
one more tidbit...

how does this affect connection pooling? I.e., if I want to maintain maxiumum connection pooling properties, would setting an object = Nothing interrupt this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top