Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I know that when you're inside of a procedure and make declarations, their scope is only within that procedure (sub or function or class).

 

I've seen mention of calling dispose to get rid of some instances of variables when unneeded, but do all variables need to be disposed in this manor?

 

If I call a sub, once that sub is over, won't it (eventually) collect all the resources from that sub?

 

What sorts of things should you dispose of, anything that involved New?

  • Administrators
Posted

http://www.xtremedotnettalk.com/showthread.php?t=74918&highlight=garbage+collection+dispose

http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69454

may be worth a read.

 

In brief you really only need to look at using dispose if the objects you are creating hold references to limited / critical / expensive resources (file handles, database connections etc.)

 

Variables that contain references to objects will ultimately be garbages collected when .Net feels there is a need. Value types (structs) will be reclaimed as soon as the procedure exits.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...