|
-
Aug 1st, 2007, 09:16 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] What is = Nothing exactly
I want to keep a class level reference to an item. Like this.
Code:
Public Class MyClass
Private MyObject as Object
End Class
So I can just write MyObject = New Object when I need it. I know that my item is a reference item so the reference is stored in the stack, and the item is stored in the heap. So, when I put MyOBject = Nothing, does that remove the item from the heap, which would allow me to go ahead and create a new object when I need to? Or, does it remove the reference from the stack, and the item becomes unusable?
I found this on MSDN:
When you assign Nothing to an object variable, it no longer refers to any object instance. If the variable had previously referred to an instance, setting it to Nothing does not terminate the instance itself. The instance is terminated, and the memory and system resources associated with it are released, only after the garbage collector (GC) detects that there are no active references remaining.
When it says "it no longer refers to an object instance" I get that it means that the item that was created after the new word is used is no longer referenced, but does it mean that it no longer is associated with a type (which would not allow me to create a new instance)?
I hope I am asking that clearly. Thank you for your help.
Ben
Using Visual Basic 2005/2008
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
|