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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Destroying Objects

Status
Not open for further replies.

FRANDAZZO

Programmer
Nov 29, 2000
60
0
0
US
Hello All,

Question -

Do you have to destroy (i.e., set to nothing) a dataset after you are done with it??? Or is it treated like a regular varaible you declare???

Example:
Dim sStr as string - you would not destroy!!!!
Dim oDS as New Dataset - do you destroy???? and if so why?

Thanks in advance,
frandazzo
 
The general rule is you want to call .Dispose on objects which contain unmanaged resources like file handles, Windows GUI handles, and database connections.

Afterwards you can set them to Nothing, but that's good practice rather than being a requirement.

Like you've seen, no need to dispose the internal .NET objects like strings, ints, etc. The garbage collector will handle those easily. Only exception to this is if you're writing for a memory constrained device (like a PocketPC or WinCE handheld) and you want to minimize the peak memory usage.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top