Need to set to Nothing?

  • Thread starter Thread starter learn
  • Start date Start date
L

learn

Guest
Hi,

If I finished using FileStream (an object?) or similar object, I close it.....but, do I need to set it to Nothing? Or, it can by set to Nothing automatically when it is out of scope?
 
The Garbage Collector (abbreviated GC) will dispose of the object for you. So, unless youre overly worried about memory usage there is Nothing to worry about. ;)
 
Garbage Collection is indeterminate, you cant tell when its going to happen. Whenever it thinks it needs to do a cleanup. You can force it by calling GC.Collect(), but this is really only beneficial if you know youve just finished using a whole lot of objects.
 
I see.....Thank you.
However, for a single object that declared/created in a procedure, can VB.Net get back the memory when the progrem runs out of the procedure?
 
As I said, it will get back the memory when it feels its appropriate. May I ask why this is an issue?
 
1. Well, I have been taught many times that we should set an object to nothing if we finished use it. Poeple said that is a good habit. I have seen a lot VB6 tutorial examples doing that. Does VB6 get GC feature?
2. When VB.Net feels like to do the GC? Until the memory near hone out?

Regards.
 
Trust both divil and I when we say you dont need to worry about it. Visual Basic 6 and its memory handling differs greatly from .NETs, and the two shouldnt be compared in that aspect.
 
Back
Top