Alex Rivera | Logout

Is there a need to set Objects to Nothing

Asked 2009-02-05T17:47:44.697
83

I always read that it is recommended to set objects to nothing, once I am done with them. But I normally use them only in functions inside forms.

Isn't the reference lost and memory released when the function scope is left, regardless of setting objects to Nothing?

i.e. is it really necessary to do:

Set db = Nothing
Set record_set = Nothing
Edit
Report

1 Answer

16

Garbage collection is rarely perfect. Even in .NET there are times where you are strongly encouraged to prompt the system to do garbage collection early.

For this reason, I explicitly both close and set to Nothing recordsets when I'm done with them.

answered 2009-02-05T18:16:42.920

Your Answer