|
-
Feb 22nd, 2002, 07:49 PM
#1
Thread Starter
Fanatic Member
Is it required to erase variables when I'm done with them?
Should I set variables to nothing and erase arrays when I'm done with them? Even when the program is shutting down??
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Feb 22nd, 2002, 08:19 PM
#2
Hyperactive Member
My understanding is that anything you create with the New keyword should be set to Nothing when you're done with it. So, if you Dim something As New ... or set something = New ..., in a routine, you should set something = Nothing before exiting the routine.
However, VB seems to clean itself up pretty well. It would probably be good practice to always initialize things when done with them, if you ever had to go to C++.
I've only once seen one of my programs app error (dr. watson) while it was still running when a treeview node which was previously referenced in an object I created was removed. The object had no where to point to anymore and sucked the life out of my program when it got referenced once more.
Ask someone who programs in C++ this question.
-
Feb 22nd, 2002, 09:07 PM
#3
Thread Starter
Fanatic Member
So in other words...All Arrays will be cleared anyways on program shutdown?
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Feb 22nd, 2002, 09:10 PM
#4
Fanatic Member
I think for a fixed-size array, they're automatically taken care of.
For dynamic arrays though, it's good idea to clean those up at the end of a function
It's especially good if you're using arrays alot, because VB is limited on memory, you can't allocate it on the fly like C++. I think...I haven't done VB in forever.
And it's good to set string to zero-length also.
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|