If any of you have worked with Java, you'll have heard about Java's garbage collector which consistently deletes object instances of objects which are no longer referenced.
I was wondering, does VB do this or do you always have to set your objects to Nothing when finished with them?
Life is short. They say "don't waste it, have fun." They're right, don't waste it...but DO redefine "fun."
VB6 uses reference counting, as all COM Classes do. In C++ you have to do the reference counting manually. In VB it's done automatically for you in most cases. You can still be susceptible to circular references which you should try to avoid. When an object is no longer referenced VB6 will free it's memory immediately. VB6 will automatically dereference objects for you when they go out of scope, so you could create an object within a sub and when the sub is finished VB will automatically clean up for you. The same goes with arrays. VB releases memory based on the scope. When a variable is out of scope its memory is released.
VB6 is really good with preventing memory leaks. Of course, they can still happen, such as using LSET the wrong way or the circular reference problem mentioned above. Another source of memory leaks is using the "End" statement to end a vb program. Other leaks can happen with 3rd party controls and the windows API. Overall, pure VB6 code handles memory really well.