G
Guest
Hi all,
What do people regard as the best practice with respect to freeing object references when you're done with them? Some people I've worked with in the past suggested that if you create an object with "New" then you should free/set it to nothing when you're finished with it, regardless of whether it's about to go out of scope or not.
In a simple example:
Private Sub DoSomething()
Dim fForm As New frmMain
fForm.Show()
'... do some things with this form
fForm.Close()
fForm = Nothing
End Sub
Is the "fForm = Nothing" necessary if garbage collection will take care of the object reference once the procedure completes? What is the best practice here?
Thanks!
Mike
What do people regard as the best practice with respect to freeing object references when you're done with them? Some people I've worked with in the past suggested that if you create an object with "New" then you should free/set it to nothing when you're finished with it, regardless of whether it's about to go out of scope or not.
In a simple example:
Private Sub DoSomething()
Dim fForm As New frmMain
fForm.Show()
'... do some things with this form
fForm.Close()
fForm = Nothing
End Sub
Is the "fForm = Nothing" necessary if garbage collection will take care of the object reference once the procedure completes? What is the best practice here?
Thanks!
Mike