I heard that assign a reference to null explicit will help gc to collect it.
Is that true?
If an object is out of scope, will it get gc quickly?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is impossible to answer in general. However, if a reference is about to go out of scope, setting it to
nulljust before it does will almost certainly achieve nothing.On the other hand, if the reference variable is long-lived, then setting it to
nullmay be useful if the referenced object is no longer needed.