rghthnrblmrc
12-14-2006, 11:28 AM
Since I am new to VBScript, I wanted to know about instantiating and destroying objects, and whether what I am doing is necessary in order to clear out memory spaces. I read somewhere that every time an instance of an object is done being used, the symbol that points to it needs be set to nothing. Is this true even as an object falls out of scope?
For instance, say I have a subroutine A() that instantiates [instance c of] an object B:
Class B
Private Sub Class_Initialize
End Sub
Private Sub Class_Terminate
End Sub
Public Sub SayHello
Response.Write("Hello World")
End Sub
End Class
Sub A
Dim c
Set c = New B
c.SayHello
Set c = Nothing ' **
End Sub
A
**Is this line actually necessary, or will the object terminate simply by falling out of scope, since it is pointed to by a variable local to the subroutine?
I believe that it is required, from what I have read, but i want to double-check. If it is required, what will happen if i do not do it? Will it eventually crash ASP? thanks.
For instance, say I have a subroutine A() that instantiates [instance c of] an object B:
Class B
Private Sub Class_Initialize
End Sub
Private Sub Class_Terminate
End Sub
Public Sub SayHello
Response.Write("Hello World")
End Sub
End Class
Sub A
Dim c
Set c = New B
c.SayHello
Set c = Nothing ' **
End Sub
A
**Is this line actually necessary, or will the object terminate simply by falling out of scope, since it is pointed to by a variable local to the subroutine?
I believe that it is required, from what I have read, but i want to double-check. If it is required, what will happen if i do not do it? Will it eventually crash ASP? thanks.